watson-developer-cloud / python-sdk

:snake: Client library to use the IBM Watson services in Python and available in pip as watson-developer-cloud
https://pypi.org/project/ibm-watson/
Apache License 2.0
1.45k stars 828 forks source link

speech to text #806

Closed tigermessi closed 2 years ago

tigermessi commented 3 years ago

`import json from os.path import join, dirname from ibm_watson import SpeechToTextV1 from ibm_watson.websocket import RecognizeCallback, AudioSource import threading from ibm_cloud_sdk_core.authenticators import IAMAuthenticator

authenticator = IAMAuthenticator('key') service = SpeechToTextV1(authenticator=authenticator) service.set_service_url('https')

models = service.list_models().get_result()

print(json.dumps(models, indent=2))

model = service.get_model('en-US_BroadbandModel').get_result()

print(json.dumps(model, indent=2))

with open('100190439830211008.mp3', 'rb') as audio_file: print(json.dumps( service.recognize( audio=audio_file, content_type='audio/mp3',

timestamps=True,

        model='zh-CN_NarrowbandModel',
        word_confidence=True).get_result(),
    indent=2))`

识别中文语音时的代码,报了503的错误,请问是哪里有误呢

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.