Ошибка импорта IBM Watson SpeechToTextV1

Я пытаюсь использовать функцию речи в текст в Уотсон, у меня есть следующий код ниже:

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.

https://github.com/watson-developer-cloud/python-sdk/tree/master/watson_developer_cloud

Ценю любую помощь.

Большое спасибо.

1 ответ

Вот как мы делаем это в машинописи. Вы можете перевести его в свой код 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>);
Другие вопросы по тегам