Microsoft cognitive-services 文本到语音问题
Microsoft cognitive-services text to speech problem
我正在尝试将 Microsoft TTS 与 python 脚本一起使用,当我使用英文单词时,输出文件完美运行,当我使用希伯来字母并将语言设置为“he-IL”时,输出文件是空。
这是来自微软示例的代码:
import azure.cognitiveservices.speech as speechsdk
# Replace with your own subscription key and region identifier from here: https://aka.ms/speech/sdkregion
speech_key, service_region = "", "westeurope"
speech_config = speechsdk.SpeechConfig(subscription=speech_key, region=service_region, speech_recognition_language="he-IL")
# Creates an audio configuration that points to an audio file.
# Replace with your own audio filename.
audio_filename = "helloworld.wav"
audio_output = speechsdk.audio.AudioOutputConfig(filename=audio_filename)
# Creates a synthesizer with the given settings
speech_synthesizer = speechsdk.SpeechSynthesizer(speech_config=speech_config, audio_config=audio_output)
# Synthesizes the text to speech.
# Replace with your own text.
text = "בדיקה שומעים אותי"
result = speech_synthesizer.speak_text_async(text).get()
# Checks result.
if result.reason == speechsdk.ResultReason.SynthesizingAudioCompleted:
print("Speech synthesized to [{}] for text [{}]".format(audio_filename, text))
elif result.reason == speechsdk.ResultReason.Canceled:
cancellation_details = result.cancellation_details
print("Speech synthesis canceled: {}".format(cancellation_details.reason))
if cancellation_details.reason == speechsdk.CancellationReason.Error:
if cancellation_details.error_details:
print("Error details: {}".format(cancellation_details.error_details))
print("Did you update the subscription info?")
speech_recognition_language
参数用于识别。您可以按照this sample设置合成语言。
关键行是
speech_config = speechsdk.SpeechConfig(subscription=speech_key, region=service_region)
# Sets the synthesis language.
speech_config.speech_synthesis_language = "he-IL"
# Creates a speech synthesizer for the specified language,
# using the default speaker as audio output.
speech_synthesizer = speechsdk.SpeechSynthesizer(speech_config=speech_config)
result = speech_synthesizer.speak_text_async(text).get()
我正在尝试将 Microsoft TTS 与 python 脚本一起使用,当我使用英文单词时,输出文件完美运行,当我使用希伯来字母并将语言设置为“he-IL”时,输出文件是空。
这是来自微软示例的代码:
import azure.cognitiveservices.speech as speechsdk
# Replace with your own subscription key and region identifier from here: https://aka.ms/speech/sdkregion
speech_key, service_region = "", "westeurope"
speech_config = speechsdk.SpeechConfig(subscription=speech_key, region=service_region, speech_recognition_language="he-IL")
# Creates an audio configuration that points to an audio file.
# Replace with your own audio filename.
audio_filename = "helloworld.wav"
audio_output = speechsdk.audio.AudioOutputConfig(filename=audio_filename)
# Creates a synthesizer with the given settings
speech_synthesizer = speechsdk.SpeechSynthesizer(speech_config=speech_config, audio_config=audio_output)
# Synthesizes the text to speech.
# Replace with your own text.
text = "בדיקה שומעים אותי"
result = speech_synthesizer.speak_text_async(text).get()
# Checks result.
if result.reason == speechsdk.ResultReason.SynthesizingAudioCompleted:
print("Speech synthesized to [{}] for text [{}]".format(audio_filename, text))
elif result.reason == speechsdk.ResultReason.Canceled:
cancellation_details = result.cancellation_details
print("Speech synthesis canceled: {}".format(cancellation_details.reason))
if cancellation_details.reason == speechsdk.CancellationReason.Error:
if cancellation_details.error_details:
print("Error details: {}".format(cancellation_details.error_details))
print("Did you update the subscription info?")
speech_recognition_language
参数用于识别。您可以按照this sample设置合成语言。
关键行是
speech_config = speechsdk.SpeechConfig(subscription=speech_key, region=service_region)
# Sets the synthesis language.
speech_config.speech_synthesis_language = "he-IL"
# Creates a speech synthesizer for the specified language,
# using the default speaker as audio output.
speech_synthesizer = speechsdk.SpeechSynthesizer(speech_config=speech_config)
result = speech_synthesizer.speak_text_async(text).get()