The model should be passed as part of the recognize
method
speech_recognition_results = speech_to_text.recognize(
audio=audio_file,
content_type='audio/mp3',
word_alternatives_threshold=0.9,
model='fr-FR_BroadbandModel'
).get_result()
Pasting the complete code that worked me for your reference
import json
from os.path import join, dirname
from ibm_watson import SpeechToTextV1
from ibm_cloud_sdk_core.authenticators import IAMAuthenticator
authenticator = IAMAuthenticator('<API_KEY>')
speech_to_text = SpeechToTextV1(
authenticator=authenticator
)
speech_to_text.set_service_url('<URL>')
with open(join(dirname(__file__), './.', 'audio-file2.mp3'),
'rb') as audio_file:
speech_recognition_results = speech_to_text.recognize(
audio=audio_file,
content_type='audio/mp3',
word_alternatives_threshold=0.9,
model='fr-FR_BroadbandModel'
).get_result()
print(json.dumps(speech_recognition_results, indent=2))
CLICK HERE to find out more related problems solutions.