forked from FunAudioLLM/CosyVoice
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
dujing
committed
Nov 27, 2024
1 parent
957eda5
commit 44e8e13
Showing
12 changed files
with
612 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from funasr import AutoModel | ||
from funasr.utils.postprocess_utils import rich_transcription_postprocess | ||
|
||
class Transcriber: | ||
def __init__(self, model="iic/SenseVoiceSmall", device="cuda:0"): | ||
self.model = AutoModel( | ||
model="iic/SenseVoiceSmall", | ||
trust_remote_code=False, | ||
remote_code="model.py", | ||
vad_model="fsmn-vad", | ||
vad_kwargs={"max_single_segment_time": 15000}, | ||
device=device) | ||
|
||
|
||
def transcribe(self, speech_or_path): | ||
res = self.model.generate( | ||
input=speech_or_path, | ||
cache={}, | ||
language="auto", # "zh", "en", "yue", "ja", "ko", "nospeech" | ||
use_itn=True, | ||
batch_size_s=60, | ||
merge_vad=True, # | ||
merge_length_s=15, | ||
) | ||
text = rich_transcription_postprocess(res[0]["text"]) | ||
return text | ||
|
||
def get_transcriber(): | ||
return Transcriber() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.