Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/google-app-engine/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python IBM Watson SpeechToTextV1导入错误_Python_Watson - Fatal编程技术网

Python IBM Watson SpeechToTextV1导入错误

Python IBM Watson SpeechToTextV1导入错误,python,watson,Python,Watson,我尝试在Watson中使用语音到文本功能,我有以下代码: from __future__ import print_function import json from os.path import join, dirname from watson_developer_cloud import SpeechToTextV1 from watson_developer_cloud.websocket import RecognizeCallback speech_to_text = Speech

我尝试在Watson中使用语音到文本功能,我有以下代码:

from __future__ import print_function
import json
from os.path import join, dirname
from watson_developer_cloud import SpeechToTextV1
from watson_developer_cloud.websocket import RecognizeCallback

speech_to_text = SpeechToTextV1(
    username='70d50ee9-c044-4670-a08e-90a84b99580d',
    password='LhielIrnK0VK',
    url='https://stream.watsonplatform.net/speech-to-text/api')

print(json.dumps(speech_to_text.list_models(), indent=2))

print(json.dumps(speech_to_text.get_model('en-US_BroadbandModel'), indent=2))

with open(join(dirname(__file__), '../resources/brian.wav'),
      'rb') as audio_file:
    print(
        json.dumps(
            speech_to_text.recognize(
            audio=audio_file,
            content_type='audio/wav',
            timestamps=True,
            word_confidence=True),
        indent=2))
我已经导入了watson_developer_cloud

谢谢你的帮助


非常感谢。

这是我们在typescript中的操作方式。您可以将其转换为python代码

import * as watson from "watson-developer-cloud";
let speechToText = new watson.SpeechToTextV1({
            username: <your_service_username>,
            password: <your_service_password>,
            version: <your_service_version>
        });

speechToText.recognize(<your_options_here>, <callback_function_here>);

欢迎来到堆栈溢出!Stack Overflow不是一个讨论论坛,它是一个问答网站,您可以在这里提出特定的编程问题,这些问题可以回答,而不是讨论。请阅读并编辑您的问题,以符合网站指南。像这样的离题问题通常是关闭的,但如果编辑为提出一个可回答的问题,可以重新打开。谢谢