From fdafd3f6bc2f04d16e7cab5afcdb1257e87a8a78 Mon Sep 17 00:00:00 2001
From: 游雁 <zhifu.gzf@alibaba-inc.com>
Date: 星期二, 17 十二月 2024 11:15:53 +0800
Subject: [PATCH] emotion2vec
---
examples/industrial_data_pretraining/sense_voice/demo.py | 52 ++++++++++++++++++++++++++++++++++------------------
1 files changed, 34 insertions(+), 18 deletions(-)
diff --git a/examples/industrial_data_pretraining/sense_voice/demo.py b/examples/industrial_data_pretraining/sense_voice/demo.py
index 07046d9..642e825 100644
--- a/examples/industrial_data_pretraining/sense_voice/demo.py
+++ b/examples/industrial_data_pretraining/sense_voice/demo.py
@@ -1,13 +1,12 @@
#!/usr/bin/env python3
# -*- encoding: utf-8 -*-
-# Copyright FunASR (https://github.com/alibaba-damo-academy/FunASR). All Rights Reserved.
+# Copyright FunASR (https://github.com/FunAudioLLM/SenseVoice). All Rights Reserved.
# MIT License (https://opensource.org/licenses/MIT)
-
from funasr import AutoModel
from funasr.utils.postprocess_utils import rich_transcription_postprocess
-model_dir = "/Users/zhifu/Downloads/modelscope_models/SenseVoiceSmall" # "iic/SenseVoiceSmall"
+model_dir = "iic/SenseVoiceSmall"
model = AutoModel(
@@ -19,30 +18,32 @@
# en
res = model.generate(
- input="/Users/zhifu/Downloads/8_output.wav",
+ input=f"{model.model_path}/example/en.mp3",
cache={},
language="auto", # "zn", "en", "yue", "ja", "ko", "nospeech"
use_itn=True,
batch_size_s=60,
merge_vad=True, #
- merge_length_s=0.1,
-)
-text = rich_transcription_postprocess(res[0]["text"])
-print(text)
-
-# en
-res = model.generate(
- input="/Users/zhifu/Downloads/8_output.wav",
- cache={},
- language="auto", # "zn", "en", "yue", "ja", "ko", "nospeech"
- use_itn=True,
- batch_size_s=60,
- merge_vad=False, #
merge_length_s=15,
)
text = rich_transcription_postprocess(res[0]["text"])
print(text)
-raise "exit"
+
+# en with timestamp
+res = model.generate(
+ input=f"{model.model_path}/example/en.mp3",
+ cache={},
+ language="auto", # "zn", "en", "yue", "ja", "ko", "nospeech"
+ use_itn=True,
+ batch_size_s=60,
+ merge_vad=True, #
+ merge_length_s=15,
+ output_timestamp=True,
+)
+print(res)
+text = rich_transcription_postprocess(res[0]["text"])
+print(text)
+
# zh
res = model.generate(
input=f"{model.model_path}/example/zh.mp3",
@@ -56,6 +57,21 @@
text = rich_transcription_postprocess(res[0]["text"])
print(text)
+# zh with timestamp
+res = model.generate(
+ input=f"{model.model_path}/example/zh.mp3",
+ cache={},
+ language="auto", # "zn", "en", "yue", "ja", "ko", "nospeech"
+ use_itn=True,
+ batch_size_s=60,
+ merge_vad=True, #
+ merge_length_s=15,
+ output_timestamp=True,
+)
+print(res)
+text = rich_transcription_postprocess(res[0]["text"])
+print(text)
+
# yue
res = model.generate(
input=f"{model.model_path}/example/yue.mp3",
--
Gitblit v1.9.1