Instructions to use MoYoYoTech/Translator with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- llama-cpp-python
How to use MoYoYoTech/Translator with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="MoYoYoTech/Translator", filename="moyoyo_asr_models/qwen2.5-1.5b-instruct-q5_0.gguf", )
llm.create_chat_completion( messages = "No input example has been defined for this model task." )
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use MoYoYoTech/Translator with llama.cpp:
Install from brew
brew install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf MoYoYoTech/Translator:Q5_0 # Run inference directly in the terminal: llama-cli -hf MoYoYoTech/Translator:Q5_0
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf MoYoYoTech/Translator:Q5_0 # Run inference directly in the terminal: llama-cli -hf MoYoYoTech/Translator:Q5_0
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf MoYoYoTech/Translator:Q5_0 # Run inference directly in the terminal: ./llama-cli -hf MoYoYoTech/Translator:Q5_0
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf MoYoYoTech/Translator:Q5_0 # Run inference directly in the terminal: ./build/bin/llama-cli -hf MoYoYoTech/Translator:Q5_0
Use Docker
docker model run hf.co/MoYoYoTech/Translator:Q5_0
- LM Studio
- Jan
- Ollama
How to use MoYoYoTech/Translator with Ollama:
ollama run hf.co/MoYoYoTech/Translator:Q5_0
- Unsloth Studio
How to use MoYoYoTech/Translator with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for MoYoYoTech/Translator to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for MoYoYoTech/Translator to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for MoYoYoTech/Translator to start chatting
- Pi
How to use MoYoYoTech/Translator with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama-server -hf MoYoYoTech/Translator:Q5_0
Configure the model in Pi
# Install Pi: npm install -g @mariozechner/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "llama-cpp": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "MoYoYoTech/Translator:Q5_0" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Hermes Agent new
How to use MoYoYoTech/Translator with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama-server -hf MoYoYoTech/Translator:Q5_0
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default MoYoYoTech/Translator:Q5_0
Run Hermes
hermes
- Docker Model Runner
How to use MoYoYoTech/Translator with Docker Model Runner:
docker model run hf.co/MoYoYoTech/Translator:Q5_0
- Lemonade
How to use MoYoYoTech/Translator with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull MoYoYoTech/Translator:Q5_0
Run and chat with the model
lemonade run user.Translator-Q5_0
List all available models
lemonade list
daihui.zhang commited on
Commit ·
7dc6a6f
1
Parent(s): c556c3a
fix bug of count word length
Browse files
transcribe/pipelines/pipe_vad.py
CHANGED
|
@@ -41,7 +41,7 @@ class VadPipe(BasePipe):
|
|
| 41 |
def process(self, in_data: MetaItem) -> MetaItem:
|
| 42 |
source_audio = in_data.source_audio
|
| 43 |
source_audio = np.frombuffer(source_audio, dtype=np.float32)
|
| 44 |
-
|
| 45 |
send_audio = b""
|
| 46 |
speech_timestamps = get_speech_timestamps(torch.Tensor(source_audio), self.model.silero_vad, sampling_rate=16000)
|
| 47 |
|
|
|
|
| 41 |
def process(self, in_data: MetaItem) -> MetaItem:
|
| 42 |
source_audio = in_data.source_audio
|
| 43 |
source_audio = np.frombuffer(source_audio, dtype=np.float32)
|
| 44 |
+
# source_audio = self.reduce_noise(source_audio)
|
| 45 |
send_audio = b""
|
| 46 |
speech_timestamps = get_speech_timestamps(torch.Tensor(source_audio), self.model.silero_vad, sampling_rate=16000)
|
| 47 |
|
transcribe/strategy.py
CHANGED
|
@@ -149,11 +149,12 @@ class TranscriptBuffer:
|
|
| 149 |
|
| 150 |
"""
|
| 151 |
|
| 152 |
-
def __init__(self):
|
| 153 |
self._segments: List[str] = collections.deque(maxlen=2) # 确认的完整段落
|
| 154 |
self._sentences: List[str] = [] # 当前段落中的短句
|
| 155 |
self._buffer: str = "" # 当前缓冲中的文本
|
| 156 |
self._current_seg_id: int = 0
|
|
|
|
| 157 |
|
| 158 |
def get_seg_id(self) -> int:
|
| 159 |
return self._current_seg_id
|
|
@@ -189,7 +190,8 @@ class TranscriptBuffer:
|
|
| 189 |
if is_end_sentence:
|
| 190 |
self.update_pending_text(stable_string)
|
| 191 |
self.commit_line()
|
| 192 |
-
current_text_len = len(self.current_not_commit_text)
|
|
|
|
| 193 |
self.update_pending_text(remaining_string)
|
| 194 |
if current_text_len >=20:
|
| 195 |
self.commit_paragraph()
|
|
@@ -224,16 +226,18 @@ class TranscriptBuffer:
|
|
| 224 |
|
| 225 |
|
| 226 |
class TranscriptStabilityAnalyzer:
|
| 227 |
-
def __init__(self) -> None:
|
| 228 |
-
self._transcript_buffer = TranscriptBuffer()
|
| 229 |
self._transcript_history = TranscriptHistory()
|
|
|
|
|
|
|
| 230 |
|
| 231 |
def merge_chunks(self, chunks: List[TranscriptChunk])->str:
|
| 232 |
return "".join(r.join() for r in chunks)
|
| 233 |
|
| 234 |
|
| 235 |
-
def analysis(self,
|
| 236 |
-
current = TranscriptChunk(items=current, separator=
|
| 237 |
self._transcript_history.add(current)
|
| 238 |
|
| 239 |
prev = self._transcript_history.previous_chunk()
|
|
|
|
| 149 |
|
| 150 |
"""
|
| 151 |
|
| 152 |
+
def __init__(self, separator):
|
| 153 |
self._segments: List[str] = collections.deque(maxlen=2) # 确认的完整段落
|
| 154 |
self._sentences: List[str] = [] # 当前段落中的短句
|
| 155 |
self._buffer: str = "" # 当前缓冲中的文本
|
| 156 |
self._current_seg_id: int = 0
|
| 157 |
+
self._separator = separator
|
| 158 |
|
| 159 |
def get_seg_id(self) -> int:
|
| 160 |
return self._current_seg_id
|
|
|
|
| 190 |
if is_end_sentence:
|
| 191 |
self.update_pending_text(stable_string)
|
| 192 |
self.commit_line()
|
| 193 |
+
current_text_len = len(self.current_not_commit_text.split(self._separator)) if self._separator else len(self.current_not_commit_text)
|
| 194 |
+
# current_text_len = len(self.current_not_commit_text.split(self._separator))
|
| 195 |
self.update_pending_text(remaining_string)
|
| 196 |
if current_text_len >=20:
|
| 197 |
self.commit_paragraph()
|
|
|
|
| 226 |
|
| 227 |
|
| 228 |
class TranscriptStabilityAnalyzer:
|
| 229 |
+
def __init__(self, separator) -> None:
|
| 230 |
+
self._transcript_buffer = TranscriptBuffer(separator=separator)
|
| 231 |
self._transcript_history = TranscriptHistory()
|
| 232 |
+
self._separator = separator
|
| 233 |
+
logger.debug(f"Current separator: {self._separator}")
|
| 234 |
|
| 235 |
def merge_chunks(self, chunks: List[TranscriptChunk])->str:
|
| 236 |
return "".join(r.join() for r in chunks)
|
| 237 |
|
| 238 |
|
| 239 |
+
def analysis(self, current: TranscriptChunk, buffer_duration: float) -> Iterator[TranscriptResult]:
|
| 240 |
+
current = TranscriptChunk(items=current, separator=self._separator)
|
| 241 |
self._transcript_history.add(current)
|
| 242 |
|
| 243 |
prev = self._transcript_history.previous_chunk()
|
transcribe/whisper_llm_serve.py
CHANGED
|
@@ -29,7 +29,7 @@ class WhisperTranscriptionService(ServeClientBase):
|
|
| 29 |
self.target_language = dst_lang # 目标翻译语言
|
| 30 |
|
| 31 |
# 转录结果稳定性管理
|
| 32 |
-
|
| 33 |
self._translate_pipe = pipe
|
| 34 |
|
| 35 |
# 音频处理相关
|
|
@@ -43,7 +43,7 @@ class WhisperTranscriptionService(ServeClientBase):
|
|
| 43 |
|
| 44 |
# 发送就绪状态
|
| 45 |
self.send_ready_state()
|
| 46 |
-
|
| 47 |
# 启动处理线程
|
| 48 |
self._translate_thread_stop = threading.Event()
|
| 49 |
self._frame_processing_thread_stop = threading.Event()
|
|
@@ -75,6 +75,7 @@ class WhisperTranscriptionService(ServeClientBase):
|
|
| 75 |
self.source_language = source_lang
|
| 76 |
self.target_language = target_lang
|
| 77 |
self.text_separator = self._get_text_separator(source_lang)
|
|
|
|
| 78 |
|
| 79 |
def add_audio_frames(self, frame_np: np.ndarray) -> None:
|
| 80 |
"""添加音频帧到处理队列"""
|
|
@@ -209,8 +210,7 @@ class WhisperTranscriptionService(ServeClientBase):
|
|
| 209 |
if not segments:
|
| 210 |
return
|
| 211 |
|
| 212 |
-
for ana_result in self._transcrible_analysis.analysis(
|
| 213 |
-
self.text_separator,segments, len(audio_buffer)/self.sample_rate):
|
| 214 |
if (cut_index :=ana_result.cut_index)>0:
|
| 215 |
# 更新音频缓冲区,移除已处理部分
|
| 216 |
self._update_audio_buffer(cut_index)
|
|
|
|
| 29 |
self.target_language = dst_lang # 目标翻译语言
|
| 30 |
|
| 31 |
# 转录结果稳定性管理
|
| 32 |
+
|
| 33 |
self._translate_pipe = pipe
|
| 34 |
|
| 35 |
# 音频处理相关
|
|
|
|
| 43 |
|
| 44 |
# 发送就绪状态
|
| 45 |
self.send_ready_state()
|
| 46 |
+
self._transcrible_analysis = None
|
| 47 |
# 启动处理线程
|
| 48 |
self._translate_thread_stop = threading.Event()
|
| 49 |
self._frame_processing_thread_stop = threading.Event()
|
|
|
|
| 75 |
self.source_language = source_lang
|
| 76 |
self.target_language = target_lang
|
| 77 |
self.text_separator = self._get_text_separator(source_lang)
|
| 78 |
+
self._transcrible_analysis = TranscriptStabilityAnalyzer(self.text_separator)
|
| 79 |
|
| 80 |
def add_audio_frames(self, frame_np: np.ndarray) -> None:
|
| 81 |
"""添加音频帧到处理队列"""
|
|
|
|
| 210 |
if not segments:
|
| 211 |
return
|
| 212 |
|
| 213 |
+
for ana_result in self._transcrible_analysis.analysis(segments, len(audio_buffer)/self.sample_rate):
|
|
|
|
| 214 |
if (cut_index :=ana_result.cut_index)>0:
|
| 215 |
# 更新音频缓冲区,移除已处理部分
|
| 216 |
self._update_audio_buffer(cut_index)
|