2016-09-26 71 views
0

我們正在使用的API無會話和蟒蛇,我們已經把「繼續:真」:語音到文本沃森中斷的沉默

高清make_completed_audio_request(URL,API_NAME =無,語言=無,時間像這樣的參數=無):

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?

+0

還有很多其他API更準確,可識別長文件。 –

+0

感謝評論@NikolayShmyrev,但我們決定使用watson作爲kewywords功能。 – avi1074

回答

0

我正在使用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)) 
+0

它工作完美!謝謝 – avi1074

相關問題