Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update with main #1305

Merged
merged 3 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion funasr/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.2
1.0.3
7 changes: 7 additions & 0 deletions runtime/python/websocket/funasr_wss_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,13 @@ async def record_from_scp(chunk_begin, chunk_size):
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:
Expand Down
5 changes: 4 additions & 1 deletion runtime/websocket/bin/funasr-wss-client-2pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,10 @@ class WebsocketClient {
funasr::Audio audio(1);
int32_t sampling_rate = audio_fs;
std::string wav_format = "pcm";
if (funasr::IsTargetFile(wav_path.c_str(), "pcm")) {
if (funasr::IsTargetFile(wav_path.c_str(), "wav")) {
if (!audio.LoadWav(wav_path.c_str(), &sampling_rate, false))
return;
} else if (funasr::IsTargetFile(wav_path.c_str(), "pcm")) {
if (!audio.LoadPcmwav(wav_path.c_str(), &sampling_rate, false)) return;
} else {
wav_format = "others";
Expand Down
2 changes: 1 addition & 1 deletion runtime/websocket/bin/funasr-wss-server-2pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ int main(int argc, char* argv[]) {
std::string s_lm_path = model_path[LM_DIR];

std::string python_cmd =
"python -m funasr.utils.runtime_sdk_download_tool --type onnx --quantize True ";
"python -m funasr.download.runtime_sdk_download_tool --type onnx --quantize True ";

if (!s_vad_path.empty()) {
std::string python_cmd_vad;
Expand Down
2 changes: 1 addition & 1 deletion runtime/websocket/bin/funasr-wss-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ int main(int argc, char* argv[]) {
std::string s_itn_path = model_path[ITN_DIR];
std::string s_lm_path = model_path[LM_DIR];

std::string python_cmd = "python -m funasr.utils.runtime_sdk_download_tool --type onnx --quantize True ";
std::string python_cmd = "python -m funasr.download.runtime_sdk_download_tool --type onnx --quantize True ";

if(vad_dir.isSet() && !s_vad_path.empty()){
std::string python_cmd_vad;
Expand Down