!wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2_amd64.deb!sudo dpkg -i libssl1.1_1.1.1f-1ubuntu2_amd64.deb!pip install azure-cognitiveservices-speech
import os
from google.colab import drive
from google.colab import files
from google.colab import auth
drive.mount('/content/drive', force_remount=True)
from azure.cognitiveservices.speech import AudioDataStream, SpeechSynthesizer
from azure.cognitiveservices.speech.audio import AudioOutputConfig
import azure.cognitiveservices.speech as speechsdk
speech_key, service_region = "4b91ee619ca64223834f8d36f3883758", "westeurope"speech_config = speechsdk.SpeechConfig(subscription=speech_key, region=service_region)
synthesizer = SpeechSynthesizer(speech_config=speech_config)
texts = ["我现在声音自然多了吧","都选择白嫖免费使用的就完事,注意要选择美国东部的服务","其他的名称只要是不重复就可以随便填,填写好就可以看到自己的key了"]
#voice_name = "zh-CN-XiaoxiaoNeural"
voice_name = "zh-CN-YunxiNeural"
ssmls = []
for text in texts:
ssml = f"<speak version='1.0' xml:lang='zh-CN' xmlns='http://www.w3.org/2001/10/synthesis' xmlns:mstts='http://www.w3.org/2001/mstts'><voice name='{voice_name}'><bookmark mark='bookmark_one'/>{text}</voice></speak>"
ssmls.append(ssml)
for i, ssml in enumerate(ssmls):
result = synthesizer.speak_ssml_async(ssml).get()
stream = AudioDataStream(result)
stream.save_to_wav_file(f"/content/drive/My Drive/text_to_speech/sound_{i}.wav")