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
- 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 new
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 new
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
Xin Zhang commited on
Commit ·
b67c020
1
Parent(s): e03f21e
[fix]: update vad threshold.
Browse files- main.py +5 -4
- transcribe/helpers/vadprocessor.py +2 -2
- transcribe/whisper_llm_serve.py +11 -7
main.py
CHANGED
|
@@ -57,16 +57,17 @@ async def root():
|
|
| 57 |
async def translate(websocket: WebSocket):
|
| 58 |
query_parameters_dict = websocket.query_params
|
| 59 |
from_lang, to_lang = query_parameters_dict.get('from'), query_parameters_dict.get('to')
|
| 60 |
-
|
| 61 |
client = WhisperTranscriptionService(
|
| 62 |
websocket,
|
| 63 |
pipe,
|
| 64 |
-
language=
|
|
|
|
| 65 |
client_uid=f"{uuid1()}",
|
| 66 |
)
|
| 67 |
|
| 68 |
|
| 69 |
-
if from_lang and to_lang:
|
| 70 |
client.set_language(from_lang, to_lang)
|
| 71 |
logger.info(f"Source lange: {from_lang} -> Dst lange: {to_lang}")
|
| 72 |
await websocket.accept()
|
|
@@ -75,7 +76,7 @@ async def translate(websocket: WebSocket):
|
|
| 75 |
frame_data = await get_audio_from_websocket(websocket)
|
| 76 |
client.add_frames(frame_data)
|
| 77 |
except WebSocketDisconnect:
|
| 78 |
-
return
|
| 79 |
|
| 80 |
if __name__ == '__main__':
|
| 81 |
freeze_support()
|
|
|
|
| 57 |
async def translate(websocket: WebSocket):
|
| 58 |
query_parameters_dict = websocket.query_params
|
| 59 |
from_lang, to_lang = query_parameters_dict.get('from'), query_parameters_dict.get('to')
|
| 60 |
+
|
| 61 |
client = WhisperTranscriptionService(
|
| 62 |
websocket,
|
| 63 |
pipe,
|
| 64 |
+
language=from_lang,
|
| 65 |
+
dst_lang=to_lang,
|
| 66 |
client_uid=f"{uuid1()}",
|
| 67 |
)
|
| 68 |
|
| 69 |
|
| 70 |
+
if from_lang and to_lang and client:
|
| 71 |
client.set_language(from_lang, to_lang)
|
| 72 |
logger.info(f"Source lange: {from_lang} -> Dst lange: {to_lang}")
|
| 73 |
await websocket.accept()
|
|
|
|
| 76 |
frame_data = await get_audio_from_websocket(websocket)
|
| 77 |
client.add_frames(frame_data)
|
| 78 |
except WebSocketDisconnect:
|
| 79 |
+
return
|
| 80 |
|
| 81 |
if __name__ == '__main__':
|
| 82 |
freeze_support()
|
transcribe/helpers/vadprocessor.py
CHANGED
|
@@ -278,12 +278,12 @@ class VadProcessor:
|
|
| 278 |
cache_s=0.15,
|
| 279 |
sr=16000
|
| 280 |
):
|
| 281 |
-
self.
|
| 282 |
self.cache_s = cache_s
|
| 283 |
self.sr = sr
|
| 284 |
self.silence_s = silence_s
|
| 285 |
|
| 286 |
-
self.vad = VadV2(self.
|
| 287 |
|
| 288 |
|
| 289 |
def process_audio(self, audio_buffer: np.ndarray):
|
|
|
|
| 278 |
cache_s=0.15,
|
| 279 |
sr=16000
|
| 280 |
):
|
| 281 |
+
self.prob_threshold = prob_threshold
|
| 282 |
self.cache_s = cache_s
|
| 283 |
self.sr = sr
|
| 284 |
self.silence_s = silence_s
|
| 285 |
|
| 286 |
+
self.vad = VadV2(self.prob_threshold, self.sr, self.silence_s * 1000, self.cache_s * 1000, max_speech_duration_s=15)
|
| 287 |
|
| 288 |
|
| 289 |
def process_audio(self, audio_buffer: np.ndarray):
|
transcribe/whisper_llm_serve.py
CHANGED
|
@@ -30,7 +30,8 @@ class WhisperTranscriptionService:
|
|
| 30 |
DISCONNECT = "DISCONNECT"
|
| 31 |
|
| 32 |
def __init__(self, websocket, pipe: TranslatePipes, language=None, dst_lang=None, client_uid=None):
|
| 33 |
-
|
|
|
|
| 34 |
self.source_language = language # 源语言
|
| 35 |
self.target_language = dst_lang # 目标翻译语言
|
| 36 |
self.client_uid = client_uid
|
|
@@ -40,7 +41,7 @@ class WhisperTranscriptionService:
|
|
| 40 |
|
| 41 |
# 音频处理相关
|
| 42 |
self.sample_rate = 16000
|
| 43 |
-
|
| 44 |
self.lock = threading.Lock()
|
| 45 |
self._frame_queue = queue.Queue()
|
| 46 |
self._vad_frame_queue = queue.Queue()
|
|
@@ -49,7 +50,7 @@ class WhisperTranscriptionService:
|
|
| 49 |
self.text_separator = self._get_text_separator(language)
|
| 50 |
self.loop = asyncio.get_event_loop()
|
| 51 |
# 发送就绪状态
|
| 52 |
-
|
| 53 |
self._transcrible_analysis = None
|
| 54 |
# 启动处理线程
|
| 55 |
self._translate_thread_stop = threading.Event()
|
|
@@ -57,7 +58,10 @@ class WhisperTranscriptionService:
|
|
| 57 |
|
| 58 |
self.translate_thread = self._start_thread(self._transcription_processing_loop)
|
| 59 |
self.frame_processing_thread = self._start_thread(self._frame_processing_loop)
|
| 60 |
-
|
|
|
|
|
|
|
|
|
|
| 61 |
self.row_number = 0
|
| 62 |
# for test
|
| 63 |
self._transcrible_time_cost = 0.
|
|
@@ -66,9 +70,9 @@ class WhisperTranscriptionService:
|
|
| 66 |
self._test_task_stop = threading.Event()
|
| 67 |
self._test_queue = queue.Queue()
|
| 68 |
self._test_thread = self._start_thread(self.test_data_loop)
|
| 69 |
-
|
| 70 |
# self._c = 0
|
| 71 |
-
|
| 72 |
def test_data_loop(self):
|
| 73 |
writer = TestDataWriter()
|
| 74 |
while not self._test_task_stop.is_set():
|
|
@@ -179,7 +183,7 @@ class WhisperTranscriptionService:
|
|
| 179 |
if audio_buffer is None or len(audio_buffer) < int(self.sample_rate):
|
| 180 |
time.sleep(0.2)
|
| 181 |
continue
|
| 182 |
-
|
| 183 |
logger.debug(f"audio buffer size: {len(audio_buffer) / self.sample_rate:.2f}s")
|
| 184 |
# try:
|
| 185 |
meta_item = self._transcribe_audio(audio_buffer)
|
|
|
|
| 30 |
DISCONNECT = "DISCONNECT"
|
| 31 |
|
| 32 |
def __init__(self, websocket, pipe: TranslatePipes, language=None, dst_lang=None, client_uid=None):
|
| 33 |
+
print('>>>>>>>>>>>>>>>> init service >>>>>>>>>>>>>>>>>>>>>>')
|
| 34 |
+
print('src_lang:', language)
|
| 35 |
self.source_language = language # 源语言
|
| 36 |
self.target_language = dst_lang # 目标翻译语言
|
| 37 |
self.client_uid = client_uid
|
|
|
|
| 41 |
|
| 42 |
# 音频处理相关
|
| 43 |
self.sample_rate = 16000
|
| 44 |
+
|
| 45 |
self.lock = threading.Lock()
|
| 46 |
self._frame_queue = queue.Queue()
|
| 47 |
self._vad_frame_queue = queue.Queue()
|
|
|
|
| 50 |
self.text_separator = self._get_text_separator(language)
|
| 51 |
self.loop = asyncio.get_event_loop()
|
| 52 |
# 发送就绪状态
|
| 53 |
+
|
| 54 |
self._transcrible_analysis = None
|
| 55 |
# 启动处理线程
|
| 56 |
self._translate_thread_stop = threading.Event()
|
|
|
|
| 58 |
|
| 59 |
self.translate_thread = self._start_thread(self._transcription_processing_loop)
|
| 60 |
self.frame_processing_thread = self._start_thread(self._frame_processing_loop)
|
| 61 |
+
if language == "zh":
|
| 62 |
+
self._vad = VadProcessor(prob_threshold=0.8, silence_s=0.2, cache_s=0.15)
|
| 63 |
+
else:
|
| 64 |
+
self._vad = VadProcessor(prob_threshold=0.7, silence_s=0.2, cache_s=0.15)
|
| 65 |
self.row_number = 0
|
| 66 |
# for test
|
| 67 |
self._transcrible_time_cost = 0.
|
|
|
|
| 70 |
self._test_task_stop = threading.Event()
|
| 71 |
self._test_queue = queue.Queue()
|
| 72 |
self._test_thread = self._start_thread(self.test_data_loop)
|
| 73 |
+
|
| 74 |
# self._c = 0
|
| 75 |
+
|
| 76 |
def test_data_loop(self):
|
| 77 |
writer = TestDataWriter()
|
| 78 |
while not self._test_task_stop.is_set():
|
|
|
|
| 183 |
if audio_buffer is None or len(audio_buffer) < int(self.sample_rate):
|
| 184 |
time.sleep(0.2)
|
| 185 |
continue
|
| 186 |
+
|
| 187 |
logger.debug(f"audio buffer size: {len(audio_buffer) / self.sample_rate:.2f}s")
|
| 188 |
# try:
|
| 189 |
meta_item = self._transcribe_audio(audio_buffer)
|