From 8900dd9497aebb7e1394d9d776c874244809ffe5 Mon Sep 17 00:00:00 2001 From: EECSMiner Date: Tue, 28 Feb 2023 13:28:39 +0800 Subject: [PATCH 1/4] modify tts.py --- python_cli_demo/tts.py | 73 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 63 insertions(+), 10 deletions(-) diff --git a/python_cli_demo/tts.py b/python_cli_demo/tts.py index 182d565..38356d0 100644 --- a/python_cli_demo/tts.py +++ b/python_cli_demo/tts.py @@ -8,6 +8,7 @@ import re import uuid import argparse +import os '''命令行参数解析''' @@ -48,7 +49,7 @@ async def transferMsTTSData(SSML_text, outputPath): # req_id = str('%032x' % random.getrandbits(128)).upper() # req_id is generated by uuid. req_id = uuid.uuid4().hex.upper() - print(req_id) + print(f" req_id:{req_id}") # wss://eastus.api.speech.microsoft.com/cognitiveservices/websocket/v1?TrafficType=AzureDemo&Authorization=bearer%20undefined&X-ConnectionId=577D1E595EEB45979BA26C056A519073 # endpoint2 = "wss://eastus.tts.speech.microsoft.com/cognitiveservices/websocket/v1?Authorization=" + \ # Auth_Token + "&X-ConnectionId=" + req_id @@ -75,8 +76,13 @@ async def transferMsTTSData(SSML_text, outputPath): end_resp_pat = re.compile('Path:turn.end') audio_stream = b'' while(True): - response = await websocket.recv() - print('receiving...') + # response = await websocket.recv() + time_seconds = 3 + try: + response = await asyncio.wait_for(websocket.recv(), timeout=time_seconds) + except TimeoutError as e: + print("response Timeout") + return # Make sure the message isn't telling us to stop if (re.search(end_resp_pat, str(response)) == None): # Check if our response is text data or the audio bytes @@ -90,9 +96,15 @@ async def transferMsTTSData(SSML_text, outputPath): pass else: break - with open(f'{outputPath}.mp3', 'wb') as audio_out: + #append ab or write wb + writeMode = "wb" if transferMsTTSData.firstWrite else "ab" + transferMsTTSData.firstWrite = False + with open(f'{outputPath}.mp3', writeMode) as audio_out: + transferMsTTSData.count +=1 + print("█"*transferMsTTSData.count, end ="") audio_out.write(audio_stream) - +transferMsTTSData.firstWrite = True +transferMsTTSData.count = 0 async def mainSeq(SSML_text, outputPath): await transferMsTTSData(SSML_text, outputPath) @@ -101,11 +113,52 @@ def get_SSML(path): with open(path,'r',encoding='utf-8') as f: return f.read() +def readFile(path): + # utf-8-sig check if a BOM exists or not and manages that for you which behaves exactly as utf-8 + with open(path,'r',encoding='utf-8-sig') as f: + return f.read() + +def fileTTS(): + chunk = "" + count = 0 + lineNum = 0 + startlineNum = 1 + print("Downloading ...") + for line in text.splitlines(): + lineNum+=1 + if startlineNum<=lineNum: + chunk+= line + if len(chunk) >200: + SSML_text =''+ chunk +'' + output_path = args.output if args.output else 'output_'+ str(int(time.time()*1000)) + count += 1 + tryTimes = 0 + maxTimes = 2 + print(f" from line {startlineNum} to line {lineNum}.",end ="") + while count != transferMsTTSData.count and tryTimes Date: Wed, 1 Mar 2023 10:44:10 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20tts=20=E5=B0=9D?= =?UTF-8?q?=E8=AF=95=E6=AC=A1=E6=95=B0bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- python_cli_demo/tts.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/python_cli_demo/tts.py b/python_cli_demo/tts.py index 38356d0..629148e 100644 --- a/python_cli_demo/tts.py +++ b/python_cli_demo/tts.py @@ -56,16 +56,17 @@ async def transferMsTTSData(SSML_text, outputPath): # 目前该接口没有认证可能很快失效 endpoint2 = f"wss://eastus.api.speech.microsoft.com/cognitiveservices/websocket/v1?TrafficType=AzureDemo&Authorization=bearer%20undefined&X-ConnectionId={req_id}" async with websockets.connect(endpoint2,extra_headers={'Origin':'https://azure.microsoft.com'}) as websocket: + # 创建WS link payload_1 = '{"context":{"system":{"name":"SpeechSDK","version":"1.12.1-rc.1","build":"JavaScript","lang":"JavaScript","os":{"platform":"Browser/Linux x86_64","name":"Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0","version":"5.0 (X11)"}}}}' message_1 = 'Path : speech.config\r\nX-RequestId: ' + req_id + '\r\nX-Timestamp: ' + \ getXTime() + '\r\nContent-Type: application/json\r\n\r\n' + payload_1 await websocket.send(message_1) - + # 发送合成语音配置,更改格式需要重新发送 payload_2 = '{"synthesis":{"audio":{"metadataOptions":{"sentenceBoundaryEnabled":false,"wordBoundaryEnabled":false},"outputFormat":"audio-16khz-32kbitrate-mono-mp3"}}}' message_2 = 'Path : synthesis.context\r\nX-RequestId: ' + req_id + '\r\nX-Timestamp: ' + \ getXTime() + '\r\nContent-Type: application/json\r\n\r\n' + payload_2 await websocket.send(message_2) - + # 发送txt文本 # payload_3 = ''+ msg_content +'' payload_3 = SSML_text message_3 = 'Path: ssml\r\nX-RequestId: ' + req_id + '\r\nX-Timestamp: ' + \ @@ -97,13 +98,11 @@ async def transferMsTTSData(SSML_text, outputPath): else: break #append ab or write wb - writeMode = "wb" if transferMsTTSData.firstWrite else "ab" - transferMsTTSData.firstWrite = False + writeMode = "wb" if transferMsTTSData.count==0 else "ab" with open(f'{outputPath}.mp3', writeMode) as audio_out: transferMsTTSData.count +=1 print("█"*transferMsTTSData.count, end ="") audio_out.write(audio_stream) -transferMsTTSData.firstWrite = True transferMsTTSData.count = 0 async def mainSeq(SSML_text, outputPath): @@ -128,20 +127,20 @@ def fileTTS(): lineNum+=1 if startlineNum<=lineNum: chunk+= line - if len(chunk) >200: + if len(chunk) >400*3: SSML_text =''+ chunk +'' output_path = args.output if args.output else 'output_'+ str(int(time.time()*1000)) count += 1 tryTimes = 0 - maxTimes = 2 + maxTimes = 1 print(f" from line {startlineNum} to line {lineNum}.",end ="") while count != transferMsTTSData.count and tryTimes Date: Wed, 1 Mar 2023 15:06:09 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20tts=20=E7=BB=93?= =?UTF-8?q?=E6=9E=84=E4=B8=BA=E6=A8=A1=E5=9D=97=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- python_cli_demo/tts.py | 288 +++++++++++++++++++++-------------------- 1 file changed, 147 insertions(+), 141 deletions(-) diff --git a/python_cli_demo/tts.py b/python_cli_demo/tts.py index 629148e..95c059d 100644 --- a/python_cli_demo/tts.py +++ b/python_cli_demo/tts.py @@ -10,155 +10,161 @@ import argparse import os +class MsTTS: -'''命令行参数解析''' -def parseArgs(): - parser = argparse.ArgumentParser(description='text2speech') - parser.add_argument('--input', dest='input', help='SSML(语音合成标记语言)的路径', type=str, required=True) - parser.add_argument('--output', dest='output', help='保存mp3文件的路径', type=str, required=False) - args = parser.parse_args() - return args - -# Fix the time to match Americanisms -def hr_cr(hr): - corrected = (hr - 1) % 24 - return str(corrected) - -# Add zeros in the right places i.e 22:1:5 -> 22:01:05 -def fr(input_string): - corr = '' - i = 2 - len(input_string) - while (i > 0): - corr += '0' - i -= 1 - return corr + input_string - -# Generate X-Timestamp all correctly formatted -def getXTime(): - now = datetime.now() - return fr(str(now.year)) + '-' + fr(str(now.month)) + '-' + fr(str(now.day)) + 'T' + fr(hr_cr(int(now.hour))) + ':' + fr(str(now.minute)) + ':' + fr(str(now.second)) + '.' + str(now.microsecond)[:3] + 'Z' - -# Async function for actually communicating with the websocket -async def transferMsTTSData(SSML_text, outputPath): - # endpoint1 = "https://azure.microsoft.com/en-gb/services/cognitive-services/text-to-speech/" - # r = requests.get(endpoint1) - # main_web_content = r.text - # # They hid the Auth key assignment for the websocket in the main body of the webpage.... - # token_expr = re.compile('token: \"(.*?)\"', re.DOTALL) - # Auth_Token = re.findall(token_expr, main_web_content)[0] - # req_id = str('%032x' % random.getrandbits(128)).upper() - # req_id is generated by uuid. - req_id = uuid.uuid4().hex.upper() - print(f" req_id:{req_id}") - # wss://eastus.api.speech.microsoft.com/cognitiveservices/websocket/v1?TrafficType=AzureDemo&Authorization=bearer%20undefined&X-ConnectionId=577D1E595EEB45979BA26C056A519073 - # endpoint2 = "wss://eastus.tts.speech.microsoft.com/cognitiveservices/websocket/v1?Authorization=" + \ - # Auth_Token + "&X-ConnectionId=" + req_id - # 目前该接口没有认证可能很快失效 - endpoint2 = f"wss://eastus.api.speech.microsoft.com/cognitiveservices/websocket/v1?TrafficType=AzureDemo&Authorization=bearer%20undefined&X-ConnectionId={req_id}" - async with websockets.connect(endpoint2,extra_headers={'Origin':'https://azure.microsoft.com'}) as websocket: - # 创建WS link - payload_1 = '{"context":{"system":{"name":"SpeechSDK","version":"1.12.1-rc.1","build":"JavaScript","lang":"JavaScript","os":{"platform":"Browser/Linux x86_64","name":"Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0","version":"5.0 (X11)"}}}}' - message_1 = 'Path : speech.config\r\nX-RequestId: ' + req_id + '\r\nX-Timestamp: ' + \ - getXTime() + '\r\nContent-Type: application/json\r\n\r\n' + payload_1 - await websocket.send(message_1) - # 发送合成语音配置,更改格式需要重新发送 - payload_2 = '{"synthesis":{"audio":{"metadataOptions":{"sentenceBoundaryEnabled":false,"wordBoundaryEnabled":false},"outputFormat":"audio-16khz-32kbitrate-mono-mp3"}}}' - message_2 = 'Path : synthesis.context\r\nX-RequestId: ' + req_id + '\r\nX-Timestamp: ' + \ - getXTime() + '\r\nContent-Type: application/json\r\n\r\n' + payload_2 - await websocket.send(message_2) - # 发送txt文本 - # payload_3 = ''+ msg_content +'' - payload_3 = SSML_text - message_3 = 'Path: ssml\r\nX-RequestId: ' + req_id + '\r\nX-Timestamp: ' + \ - getXTime() + '\r\nContent-Type: application/ssml+xml\r\n\r\n' + payload_3 - await websocket.send(message_3) - - # Checks for close connection message - end_resp_pat = re.compile('Path:turn.end') - audio_stream = b'' - while(True): - # response = await websocket.recv() - time_seconds = 3 - try: - response = await asyncio.wait_for(websocket.recv(), timeout=time_seconds) - except TimeoutError as e: - print("response Timeout") - return - # Make sure the message isn't telling us to stop - if (re.search(end_resp_pat, str(response)) == None): - # Check if our response is text data or the audio bytes - if type(response) == type(bytes()): - # Extract binary data - try: - needle = b'Path:audio\r\n' - start_ind = response.find(needle) + len(needle) - audio_stream += response[start_ind:] - except: - pass - else: - break + def __init__(self,SSML_text=''): + self.audio_stream = b'' + self.SSML_text = SSML_text + self.__result = False + # Generate X-Timestamp all correctly formatted + def getXTime(): + # Fix the time to match Americanisms + def hr_cr(hr): + corrected = (hr - 1) % 24 + return str(corrected) + + # Add zeros in the right places i.e 22:1:5 -> 22:01:05 + def fr(input_string): + corr = '' + i = 2 - len(input_string) + while (i > 0): + corr += '0' + i -= 1 + return corr + input_string + + now = datetime.now() + return fr(str(now.year)) + '-' + fr(str(now.month)) + '-' + fr(str(now.day)) + 'T' + fr(hr_cr(int(now.hour))) + ':' + fr(str(now.minute)) + ':' + fr(str(now.second)) + '.' + str(now.microsecond)[:3] + 'Z' + + # Async function for actually communicating with the websocket + async def transferMsTTSData(self): + # endpoint1 = "https://azure.microsoft.com/en-gb/services/cognitive-services/text-to-speech/" + # r = requests.get(endpoint1) + # main_web_content = r.text + # # They hid the Auth key assignment for the websocket in the main body of the webpage.... + # token_expr = re.compile('token: \"(.*?)\"', re.DOTALL) + # Auth_Token = re.findall(token_expr, main_web_content)[0] + # req_id = str('%032x' % random.getrandbits(128)).upper() + # req_id is generated by uuid. + req_id = uuid.uuid4().hex.upper() + print(f" req_id:{req_id}") + # wss://eastus.api.speech.microsoft.com/cognitiveservices/websocket/v1?TrafficType=AzureDemo&Authorization=bearer%20undefined&X-ConnectionId=577D1E595EEB45979BA26C056A519073 + # endpoint2 = "wss://eastus.tts.speech.microsoft.com/cognitiveservices/websocket/v1?Authorization=" + \ + # Auth_Token + "&X-ConnectionId=" + req_id + # 目前该接口没有认证可能很快失效 + endpoint2 = f"wss://eastus.api.speech.microsoft.com/cognitiveservices/websocket/v1?TrafficType=AzureDemo&Authorization=bearer%20undefined&X-ConnectionId={req_id}" + async with websockets.connect(endpoint2,extra_headers={'Origin':'https://azure.microsoft.com'}) as websocket: + # 创建WS link + payload_1 = '{"context":{"system":{"name":"SpeechSDK","version":"1.12.1-rc.1","build":"JavaScript","lang":"JavaScript","os":{"platform":"Browser/Linux x86_64","name":"Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0","version":"5.0 (X11)"}}}}' + message_1 = 'Path : speech.config\r\nX-RequestId: ' + req_id + '\r\nX-Timestamp: ' + \ + getXTime() + '\r\nContent-Type: application/json\r\n\r\n' + payload_1 + await websocket.send(message_1) + + # 发送合成语音配置,更改格式需要重新发送 + payload_2 = '{"synthesis":{"audio":{"metadataOptions":{"sentenceBoundaryEnabled":false,"wordBoundaryEnabled":false},"outputFormat":"audio-16khz-32kbitrate-mono-mp3"}}}' + message_2 = 'Path : synthesis.context\r\nX-RequestId: ' + req_id + '\r\nX-Timestamp: ' + \ + getXTime() + '\r\nContent-Type: application/json\r\n\r\n' + payload_2 + await websocket.send(message_2) + + # 发送SSML文本 + # payload_3 = ''+ msg_content +'' + payload_3 = self.SSML_text + message_3 = 'Path: ssml\r\nX-RequestId: ' + req_id + '\r\nX-Timestamp: ' + \ + getXTime() + '\r\nContent-Type: application/ssml+xml\r\n\r\n' + payload_3 + await websocket.send(message_3) + + # Checks for close connection message + end_resp_pat = re.compile('Path:turn.end') + while(True): + # response = await websocket.recv() + time_seconds = 5 + try: + response = await asyncio.wait_for(websocket.recv(), timeout=time_seconds) + except TimeoutError as e: + self.__result = False#"response Timeout" + break + # Make sure the message isn't telling us to stop + if (re.search(end_resp_pat, str(response)) == None): + # Check if our response is text data or the audio bytes + if type(response) == type(bytes()): + # Extract binary data + try: + needle = b'Path:audio\r\n' + start_ind = response.find(needle) + len(needle) + self.audio_stream += response[start_ind:] + except: + pass + else: + self.__result = True#"response complete" + break + + async def getAudioStream(self): + await asyncio.get_event_loop().run_until_complete(self.transferMsTTSData()) + return self.__result + + + +class TTSHandler: + def __init__(self,writeIndex=0): + args = self.parseArgs() + self.fileType = os.path.splitext(args.input)[-1] + self.output_path = args.output if args.output else 'output_'+ str(int(time.time()*1000)) + self.text = self.readFile(args.input) + if self.fileType=='.xml': + ttsHandle = MsTTS(self.text) + if(ttsHandle.getAudioStream()): + saveDate2MP3(ttsHandle.audio_stream,self.output_path) + else: + self.textArray = self.splitext(self.text) + self.writeIndex = writeIndex + for(t in self.textArray): + ttsHandle = MsTTS(wrapinSSML(t)) + if(ttsHandle.getAudioStream()): + self.writeMode = "ab" if self.writeIndex else "wb" + self.writeIndex +=1 + saveDate2MP3(ttsHandle.audio_stream,self.output_path,self.writeMode) + else: + print(f"fail to get Audio Stream ,writeIndex {self.writeIndex}") + break + + # 命令行参数解析 + def parseArgs(self): + parser = argparse.ArgumentParser(description='text2speech') + parser.add_argument('--input', dest='input', help='SSML(语音合成标记语言)的路径', type=str, required=True) + parser.add_argument('--output', dest='output', help='保存mp3文件的路径', type=str, required=False) + args = parser.parse_args() + return args + + def saveDate2MP3(self,audio_stream,outputPath,writeMode = "wb"): #append ab or write wb - writeMode = "wb" if transferMsTTSData.count==0 else "ab" with open(f'{outputPath}.mp3', writeMode) as audio_out: - transferMsTTSData.count +=1 - print("█"*transferMsTTSData.count, end ="") audio_out.write(audio_stream) -transferMsTTSData.count = 0 - -async def mainSeq(SSML_text, outputPath): - await transferMsTTSData(SSML_text, outputPath) - -def get_SSML(path): - with open(path,'r',encoding='utf-8') as f: - return f.read() - -def readFile(path): - # utf-8-sig check if a BOM exists or not and manages that for you which behaves exactly as utf-8 - with open(path,'r',encoding='utf-8-sig') as f: - return f.read() - -def fileTTS(): - chunk = "" - count = 0 - lineNum = 0 - startlineNum = 1 - print("Downloading ...") - for line in text.splitlines(): - lineNum+=1 - if startlineNum<=lineNum: - chunk+= line - if len(chunk) >400*3: - SSML_text =''+ chunk +'' - output_path = args.output if args.output else 'output_'+ str(int(time.time()*1000)) - count += 1 - tryTimes = 0 - maxTimes = 1 - print(f" from line {startlineNum} to line {lineNum}.",end ="") - while count != transferMsTTSData.count and tryTimes1 and len(res[-1])'+ text +'' + return SSML_text if __name__ == "__main__": - args = parseArgs() - text = readFile(args.input) - fileExt = os.path.splitext(args.input)[-1] - if fileExt=='.xml': - SSML_text = readFile(args.input) - output_path = args.output if args.output else 'output_'+ str(int(time.time()*1000)) - asyncio.get_event_loop().run_until_complete(mainSeq(SSML_text, output_path)) - else: - fileTTS() + TTSHandler() # writeIndex 是读取音频失败时,文本array 的索引 print(' completed') # python tts.py --input SSML.xml # python tts.py --input SSML.xml --output 保存文件名 # python tts.py --input txt文件 --output 保存文件名 - # python tts.py --input 教案.txt --output hii \ No newline at end of file + # python tts.py --input 教案.txt --output hiii \ No newline at end of file From d1ee0e55696d63e56948bfe4ad54a6c62164f56c Mon Sep 17 00:00:00 2001 From: EECSMiner Date: Wed, 1 Mar 2023 15:38:17 +0800 Subject: [PATCH 4/4] =?UTF-8?q?add=20new=20command=20python=20tts.py=20--i?= =?UTF-8?q?nput=20txtFile.ext=20--output=20=E4=BF=9D=E5=AD=98=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- python_cli_demo/tts.py | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/python_cli_demo/tts.py b/python_cli_demo/tts.py index 95c059d..a6189ab 100644 --- a/python_cli_demo/tts.py +++ b/python_cli_demo/tts.py @@ -17,7 +17,7 @@ def __init__(self,SSML_text=''): self.SSML_text = SSML_text self.__result = False # Generate X-Timestamp all correctly formatted - def getXTime(): + def getXTime(self): # Fix the time to match Americanisms def hr_cr(hr): corrected = (hr - 1) % 24 @@ -56,20 +56,20 @@ async def transferMsTTSData(self): # 创建WS link payload_1 = '{"context":{"system":{"name":"SpeechSDK","version":"1.12.1-rc.1","build":"JavaScript","lang":"JavaScript","os":{"platform":"Browser/Linux x86_64","name":"Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0","version":"5.0 (X11)"}}}}' message_1 = 'Path : speech.config\r\nX-RequestId: ' + req_id + '\r\nX-Timestamp: ' + \ - getXTime() + '\r\nContent-Type: application/json\r\n\r\n' + payload_1 + self.getXTime() + '\r\nContent-Type: application/json\r\n\r\n' + payload_1 await websocket.send(message_1) # 发送合成语音配置,更改格式需要重新发送 payload_2 = '{"synthesis":{"audio":{"metadataOptions":{"sentenceBoundaryEnabled":false,"wordBoundaryEnabled":false},"outputFormat":"audio-16khz-32kbitrate-mono-mp3"}}}' message_2 = 'Path : synthesis.context\r\nX-RequestId: ' + req_id + '\r\nX-Timestamp: ' + \ - getXTime() + '\r\nContent-Type: application/json\r\n\r\n' + payload_2 + self.getXTime() + '\r\nContent-Type: application/json\r\n\r\n' + payload_2 await websocket.send(message_2) # 发送SSML文本 # payload_3 = ''+ msg_content +'' payload_3 = self.SSML_text message_3 = 'Path: ssml\r\nX-RequestId: ' + req_id + '\r\nX-Timestamp: ' + \ - getXTime() + '\r\nContent-Type: application/ssml+xml\r\n\r\n' + payload_3 + self.getXTime() + '\r\nContent-Type: application/ssml+xml\r\n\r\n' + payload_3 await websocket.send(message_3) # Checks for close connection message @@ -97,8 +97,8 @@ async def transferMsTTSData(self): self.__result = True#"response complete" break - async def getAudioStream(self): - await asyncio.get_event_loop().run_until_complete(self.transferMsTTSData()) + def getAudioStream(self): + asyncio.get_event_loop().run_until_complete(self.transferMsTTSData()) return self.__result @@ -112,16 +112,16 @@ def __init__(self,writeIndex=0): if self.fileType=='.xml': ttsHandle = MsTTS(self.text) if(ttsHandle.getAudioStream()): - saveDate2MP3(ttsHandle.audio_stream,self.output_path) + self.saveDate2MP3(ttsHandle.audio_stream,self.output_path) else: self.textArray = self.splitext(self.text) self.writeIndex = writeIndex - for(t in self.textArray): - ttsHandle = MsTTS(wrapinSSML(t)) + for t in self.textArray: + ttsHandle = MsTTS(self.wrapinSSML(t)) if(ttsHandle.getAudioStream()): self.writeMode = "ab" if self.writeIndex else "wb" self.writeIndex +=1 - saveDate2MP3(ttsHandle.audio_stream,self.output_path,self.writeMode) + self.saveDate2MP3(ttsHandle.audio_stream,self.output_path,self.writeMode) else: print(f"fail to get Audio Stream ,writeIndex {self.writeIndex}") break @@ -166,5 +166,4 @@ def wrapinSSML(self,text): # python tts.py --input SSML.xml # python tts.py --input SSML.xml --output 保存文件名 - # python tts.py --input txt文件 --output 保存文件名 - # python tts.py --input 教案.txt --output hiii \ No newline at end of file + # python tts.py --input txtFile.ext --output 保存文件名 \ No newline at end of file