语音到 Text Watson 被沉默打断
Speech to Text Watson interrupt by silence
我们正在使用 API 无会话和 python,我们将 'continue:True' 参数设置为这样:
def make_completed_audio_request(url, API_name=None, 语言=None, 时间=None):
username, password, endpoint, lan=select_voice_api(name=API_name, language=language)
audio = get_complete_audio(url, api_name=API_name, time=time)
endpoint=get_post_endpoint(url=endpoint, api_name=API_name)
if audio:
list_audio=get_speakers_by_audio(audio[1].name)
headers={'content-type': audio[2]}
params = {'model': lan,
'continuous':True,
'timestamps': True}
if language and (API_name == 'watson' or API_name == 'WATSON'):
print 'enviando request'
response = requests.post(url=endpoint, auth=(username, password),
params=params, data=audio[1], headers=headers)
print 'cladificando error'
error_clasifier(code=response.status_code)
else:
response = requests.post(url=endpoint, auth=(username, password),
params=params, data=audio[1], headers=headers)
error_clasifier(code=response.status_code)
if response:
return response, list_audio, True, None
else:
return None, None, False, None
但它仍然不起作用,它会在它发现的第一个沉默中切断转录
我做错了什么?还有其他方法可以将其发送到 API 吗?
我正在使用 watson_developer_cloud API。它易于使用,更重要的是 - 它有效。这是代码示例:
import json
from os.path import join, dirname
from watson_developer_cloud import SpeechToTextV1
speech_to_text = SpeechToTextV1(
username="yourusername",
password="yourpassword",
x_watson_learning_opt_out=False)
with open(join(dirname(__file__), 'test.wav'), 'rb') as audio_file:
data = json.dumps(speech_to_text.recognize(audio_file, content_type='audio/wav', word_confidence=True, continuous=True, word_alternatives_threshold=0, max_alternatives=10))
我们正在使用 API 无会话和 python,我们将 'continue:True' 参数设置为这样:
def make_completed_audio_request(url, API_name=None, 语言=None, 时间=None):
username, password, endpoint, lan=select_voice_api(name=API_name, language=language)
audio = get_complete_audio(url, api_name=API_name, time=time)
endpoint=get_post_endpoint(url=endpoint, api_name=API_name)
if audio:
list_audio=get_speakers_by_audio(audio[1].name)
headers={'content-type': audio[2]}
params = {'model': lan,
'continuous':True,
'timestamps': True}
if language and (API_name == 'watson' or API_name == 'WATSON'):
print 'enviando request'
response = requests.post(url=endpoint, auth=(username, password),
params=params, data=audio[1], headers=headers)
print 'cladificando error'
error_clasifier(code=response.status_code)
else:
response = requests.post(url=endpoint, auth=(username, password),
params=params, data=audio[1], headers=headers)
error_clasifier(code=response.status_code)
if response:
return response, list_audio, True, None
else:
return None, None, False, None
但它仍然不起作用,它会在它发现的第一个沉默中切断转录
我做错了什么?还有其他方法可以将其发送到 API 吗?
我正在使用 watson_developer_cloud API。它易于使用,更重要的是 - 它有效。这是代码示例:
import json
from os.path import join, dirname
from watson_developer_cloud import SpeechToTextV1
speech_to_text = SpeechToTextV1(
username="yourusername",
password="yourpassword",
x_watson_learning_opt_out=False)
with open(join(dirname(__file__), 'test.wav'), 'rb') as audio_file:
data = json.dumps(speech_to_text.recognize(audio_file, content_type='audio/wav', word_confidence=True, continuous=True, word_alternatives_threshold=0, max_alternatives=10))