From 646eda72e3f495b33b48e73949f4a54909bb0de4 Mon Sep 17 00:00:00 2001
From: 雾聪 <wucong.lyb@alibaba-inc.com>
Date: 星期五, 26 一月 2024 10:04:19 +0800
Subject: [PATCH] update clients for 2pass

---
 runtime/python/websocket/funasr_wss_client.py |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/runtime/python/websocket/funasr_wss_client.py b/runtime/python/websocket/funasr_wss_client.py
index 92dc548..a2d8889 100644
--- a/runtime/python/websocket/funasr_wss_client.py
+++ b/runtime/python/websocket/funasr_wss_client.py
@@ -186,6 +186,13 @@
         if wav_path.endswith(".pcm"):
             with open(wav_path, "rb") as f:
                 audio_bytes = f.read()
+        elif wav_path.endswith(".wav"):
+            import wave
+            with wave.open(wav_path, "rb") as wav_file:
+                params = wav_file.getparams()
+                sample_rate = wav_file.getframerate()
+                frames = wav_file.readframes(wav_file.getnframes())
+                audio_bytes = bytes(frames)        
         else:
             wav_format = "others"
             with open(wav_path, "rb") as f:

--
Gitblit v1.9.1