我试图使用watson开发人员云python库与IBM Speech to Text API接口,以检测某些文本中存在哪些音素或音节。但是,我遇到了一些与所需的参数customization_id有关的问题,我希望有人能够提供更多的上下文来说明要传递的值。我看完医生后就听不懂了。下面是一个代码片段:
from watson_developer_cloud import TextToSpeechV1, WatsonApiException
API_KEY = "<redacted>"
URL = "https://gateway-wdc.watsonplatform.net/text-to-speech/api"
client = TextToSpeechV1(iam_apikey=API_KEY, url=URL)
try:
#response = client.get_word(customization_id="1", word="HELLO WORLD")
#> Malformed GUID: '1'
#response = client.get_word(word="HELLO WORLD")
#> get_word() missing 1 required positional argument: 'customization_id'
#response = client.get_word(customization_id=None, word="HELLO WORLD")
#> ValueError: customization_id must be provided
#response = client.get_word(customization_id="GA", word="HELLO WORLD")
#> ERROR 400: Malformed GUID: 'GA'
# WHAT VALUE TO USE FOR CUSTOMIZATION_ID ??? ...
response = client.get_word(customization_id="_______", word="HELLO WORLD") #>
print("RESPONSE")
print(type(response))
except WatsonApiException as ex:
print(f"ERROR {str(ex.code)}: {ex.message}")编辑:有可能期望值是新的自定义语音模型的标识符。我已经开始调查这个策略这里,但不幸的是,我也在这个策略上遇到了问题。这种方法可能类似于:
# ...
voice_model_response = client.create_voice_model(
name="My Custom Model",
language=LANG,
description="to get a valid 'customization_id' value..."
).get_result()
customization_id = voice_model_response["customization_id"]
response = client.get_word(customization_id=customization_id, word="HELLO WORLD")
# ...发布于 2019-02-14 22:56:12
结果发现我使用了错误的URL和错误的API密钥。在将URL修正为真正的"https://gateway-wdc.watsonplatform.net/text-to-speech/api“并创建和升级一个新的标准级别文本到语音服务并使用该服务的API键之后,我能够实现我在问题的更新部分中提到的两步过程。
发布于 2019-02-10 07:39:41
我想你把演讲稿的文档看错了。
您可以创建一个自定义来修改语料库使用语音检测单词的方式。
https://cloud.ibm.com/apidocs/speech-to-text?code=python#add-custom-words
但要做到这一点,你需要创建一个定制,这是你不能做的一个小账户。
https://cloud.ibm.com/apidocs/speech-to-text?code=python#create-a-custom-language-model
您可以使用API列出您已经创建的自定义。
https://cloud.ibm.com/apidocs/speech-to-text?code=python#list-custom-language-models
https://stackoverflow.com/questions/54599355
复制相似问题