无法在Windows上通过Python生成Azure TTS

nfzehxib  于 2023-08-07  发布在  Windows
关注(0)|答案(1)|浏览(108)

所以我尝试使用Azure认知语音来生成TTS,但它没有生成任何输出,这段代码在ubuntu和mac上运行得很好,但在我的windows机器上无法工作

import azure.cognitiveservices.speech as speechsdk
from azure.cognitiveservices.speech import AudioDataStream, SpeechConfig, SpeechSynthesizer, SpeechSynthesisOutputFormat
from azure.cognitiveservices.speech.audio import AudioOutputConfig

close_file = "tes.wav"

closer = "placeholder text commonly used in the graphic, print, and publishing industries for previewing layouts and visual mockups."
speech_config = SpeechConfig(subscription="API", region="asdasd")
speech_config.speech_synthesis_voice_name = "en-US-GuyNeural"
audio_config = AudioOutputConfig(filename=close_file)
synthesizer = SpeechSynthesizer(speech_config=speech_config, audio_config=audio_config)
synthesizer.speak_text_async(closer)

字符串

shyt4zoc

shyt4zoc1#

  • 我对你的代码做了一些修改,在windows上得到了带有输入文本的音频输出。*
    验证码:
import azure.cognitiveservices.speech as speechsdk
from azure.cognitiveservices.speech import AudioDataStream, SpeechConfig, SpeechSynthesizer, SpeechSynthesisOutputFormat
from azure.cognitiveservices.speech.audio import AudioOutputConfig

try:
    close_file = "kam.wav"
    closer = "Hi kamali, I am your personal assistant. I am here to help you. "
    speech_config = SpeechConfig(subscription="<speech-key>", region="<speech-region>")
    speech_config.speech_synthesis_voice_name = "en-US-GuyNeural"
    audio_config = AudioOutputConfig(filename=close_file)
    synthesizer = SpeechSynthesizer(speech_config=speech_config, audio_config=audio_config)
    synthesizer.speak_text_async(closer).get()
    
    print("Text successfully converted to speech.")

except Exception as ex:
    print("Error: ", ex)

字符串

输出:

它成功运行,并给出如下输入文本的音频输出,


的数据

相关问题