【问题标题】:How to use Speech to text and Text to Speech APIs from IBM Bluemix in Python如何在 Python 中使用 IBM Bluemix 中的 Speech to text 和 Text to Speech API
【发布时间】:2017-03-06 07:37:13
【问题描述】:

我现有的代码是:

import requests
 import json
 import os

 url = "https://stream.watsonplatform.net/speech-to-text-beta/api/v1/recognize"
 username= "USERNAME" 
 password= "PASSWORD" 

 filepath = '/home/user/myfamily.ogg'  # path to file
 filename = os.path.basename(filepath)

 audio = open(filepath,'rb')

 files_input = {
     "audioFile":(filename,audio,'audio/ogg')    
 }

 response = requests.post(url, auth=(username, password), headers={"Content-Type": "audio/wav"},files=files_input)

 print('stauts_code: {} (reason: {})'.format(response.status_code, response.reason))

 print response.text

但是,我收到以下错误: status_code:405(原因:不允许的方法)

{
  "error": "Your browser approached me (at /text-to-speech/api) with the method \"POST\".  I only allow the methods HEAD, GET here.",
  "code": 405,
  "code_description": "Method Not Allowed"
}

我使用 .ogg 文件作为音频输入。

【问题讨论】:

标签: python ibm-cloud text-to-speech speech-to-text watson


【解决方案1】:

您使用的网址 (https://stream.watsonplatform.net/speech-to-text-beta/api/v1/recognize) 不再有效,请注意 -beta,它在很久以前就已被弃用。你是从哪里弄来的?

请使用以下网址:https://stream.watsonplatform.net/speech-to-text/api/v1/recognize

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-07-28
    • 1970-01-01
    • 2017-06-11
    • 1970-01-01
    • 1970-01-01
    • 2019-07-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多