From 6e8a9b6d445531815bb8b2566ddbc70989e14378 Mon Sep 17 00:00:00 2001 From: SoloPro-Git <137033760@qq.com> Date: Wed, 29 Jun 2022 16:48:21 +0800 Subject: [PATCH] fix client Parameter : sample rate not work --- paddlespeech/server/utils/audio_handler.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/paddlespeech/server/utils/audio_handler.py b/paddlespeech/server/utils/audio_handler.py index e3d90d469..e7786d46d 100644 --- a/paddlespeech/server/utils/audio_handler.py +++ b/paddlespeech/server/utils/audio_handler.py @@ -447,6 +447,7 @@ class TTSHttpHandler: sample_rate (int, optional): audio sample rate, 0 means the same as model. Defaults to 0. output (str, optional): save audio path. Defaults to None. """ + sample_rate = 24000 if sample_rate == 0 else sample_rate # 1. Create request params = { "text": text, @@ -482,14 +483,14 @@ class TTSHttpHandler: self.t.start() self.start_play = False all_bytes += audio - chunk_duration_list.append(len(audio) / 2.0 / 24000) + chunk_duration_list.append(len(audio) / 2.0 / sample_rate) final_response = time.time() - st - duration = len(all_bytes) / 2.0 / 24000 + duration = len(all_bytes) / 2.0 / sample_rate html.close() # when stream=True if output is not None: - save_audio_success = save_audio(all_bytes, output) + save_audio_success = save_audio(all_bytes, output, sample_rate=sample_rate) else: save_audio_success = False