Fix custom SSML support

This commit is contained in:
rany
2021-06-10 20:51:00 +03:00
parent f5bde41eab
commit 8d022ff230
2 changed files with 5 additions and 2 deletions

View File

@@ -1,6 +1,6 @@
[metadata] [metadata]
name = edge-tts name = edge-tts
version = 2.0.6 version = 2.0.7
author = rany author = rany
author_email = ranygh@riseup.net author_email = ranygh@riseup.net
description = Microsoft Edge's TTS description = Microsoft Edge's TTS

View File

@@ -120,7 +120,7 @@ class Communicate:
message+="<voice name='" + voice + "'>" + "<prosody pitch='" + pitch + "' rate ='" + rate + "' volume='" + volume + "'>" + text + '</prosody></voice></speak>' message+="<voice name='" + voice + "'>" + "<prosody pitch='" + pitch + "' rate ='" + rate + "' volume='" + volume + "'>" + text + '</prosody></voice></speak>'
return message return message
async def run(self, msg, sentenceBoundary=False, wordBoundary=False, codec="audio-24khz-48kbitrate-mono-mp3", voice="Microsoft Server Speech Text to Speech Voice (en-US, AriaNeural)", pitch="+0Hz", rate="+0%", volume="+0%", customspeak=False): async def run(self, msgs, sentenceBoundary=False, wordBoundary=False, codec="audio-24khz-48kbitrate-mono-mp3", voice="Microsoft Server Speech Text to Speech Voice (en-US, AriaNeural)", pitch="+0Hz", rate="+0%", volume="+0%", customspeak=False):
sentenceBoundary = str(sentenceBoundary).lower() sentenceBoundary = str(sentenceBoundary).lower()
wordBoundary = str(wordBoundary).lower() wordBoundary = str(wordBoundary).lower()
@@ -128,6 +128,9 @@ class Communicate:
wsmax = 2 ** 16 wsmax = 2 ** 16
overhead = len(self.mkssmlmsg("", voice, pitch, rate, volume, customspeak=False).encode('utf-8')) overhead = len(self.mkssmlmsg("", voice, pitch, rate, volume, customspeak=False).encode('utf-8'))
msgs = _minimize(escape(removeIncompatibleControlChars(msg)), b" ", wsmax - overhead) msgs = _minimize(escape(removeIncompatibleControlChars(msg)), b" ", wsmax - overhead)
else:
if type(msgs) is str:
msgs = [msgs]
async with websockets.connect( async with websockets.connect(
wssUrl + "&ConnectionId=" + connectId(), wssUrl + "&ConnectionId=" + connectId(),