Instructions to use MoYoYoTech/Translator with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use MoYoYoTech/Translator with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -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 serve -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/ggml-org/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-app # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama serve -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
- Llama new
- LM Studio
- Jan
- Ollama
How to use MoYoYoTech/Translator with Ollama:
ollama run hf.co/MoYoYoTech/Translator:Q5_0
- Unsloth Desktop
- 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 serve -hf MoYoYoTech/Translator:Q5_0
Configure the model in Pi
# Install Pi: npm install -g @earendil-works/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
- 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
- Hermes Agent
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 serve -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
- Atomic Chat
- OpenClaw
How to use MoYoYoTech/Translator with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf MoYoYoTech/Translator:Q5_0
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:8080/v1 \ --custom-model-id "MoYoYoTech/Translator:Q5_0" \ --custom-provider-id llama-cpp \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
Download transcribe/utils.py from MoYoYoTech/Translator: direct link, hf CLI and curl.
- Browser
- Download file 4.19 kB
-
https://huggingface.co/MoYoYoTech/Translator/resolve/65a4e8d90a3affe5eea79c24dd863690dfa2d95e/transcribe/utils.py
- Command line
-
hf download hf://MoYoYoTech/Translator@65a4e8d90a3affe5eea79c24dd863690dfa2d95e/transcribe/utils.py
-
curl -L -o utils.py https://huggingface.co/MoYoYoTech/Translator/resolve/65a4e8d90a3affe5eea79c24dd863690dfa2d95e/transcribe/utils.py
4.19 kB
| import os | |
| import textwrap | |
| from pathlib import Path | |
| import logging | |
| import numpy as np | |
| from scipy.io.wavfile import write | |
| import config | |
| import csv | |
| import av | |
| def log_block(key: str, value, unit=''): | |
| if config.DEBUG: | |
| return | |
| """格式化输出日志内容""" | |
| key_fmt = f"[ {key.ljust(25)}]" # 左对齐填充 | |
| val_fmt = f"{value} {unit}".strip() | |
| logging.info(f"{key_fmt}: {val_fmt}") | |
| def clear_screen(): | |
| """Clears the console screen.""" | |
| os.system("cls" if os.name == "nt" else "clear") | |
| def print_transcript(text): | |
| """Prints formatted transcript text.""" | |
| wrapper = textwrap.TextWrapper(width=60) | |
| for line in wrapper.wrap(text="".join(text)): | |
| print(line) | |
| def format_time(s): | |
| """Convert seconds (float) to SRT time format.""" | |
| hours = int(s // 3600) | |
| minutes = int((s % 3600) // 60) | |
| seconds = int(s % 60) | |
| milliseconds = int((s - int(s)) * 1000) | |
| return f"{hours:02}:{minutes:02}:{seconds:02},{milliseconds:03}" | |
| def create_srt_file(segments, resampled_file): | |
| with open(resampled_file, 'w', encoding='utf-8') as srt_file: | |
| segment_number = 1 | |
| for segment in segments: | |
| start_time = format_time(float(segment['start'])) | |
| end_time = format_time(float(segment['end'])) | |
| text = segment['text'] | |
| srt_file.write(f"{segment_number}\n") | |
| srt_file.write(f"{start_time} --> {end_time}\n") | |
| srt_file.write(f"{text}\n\n") | |
| segment_number += 1 | |
| def resample(file: str, sr: int = 16000): | |
| """ | |
| Resample the audio file to 16kHz. | |
| Args: | |
| file (str): The audio file to open | |
| sr (int): The sample rate to resample the audio if necessary | |
| Returns: | |
| resampled_file (str): The resampled audio file | |
| """ | |
| container = av.open(file) | |
| stream = next(s for s in container.streams if s.type == 'audio') | |
| resampler = av.AudioResampler( | |
| format='s16', | |
| layout='mono', | |
| rate=sr, | |
| ) | |
| resampled_file = Path(file).stem + "_resampled.wav" | |
| output_container = av.open(resampled_file, mode='w') | |
| output_stream = output_container.add_stream('pcm_s16le', rate=sr) | |
| output_stream.layout = 'mono' | |
| for frame in container.decode(audio=0): | |
| frame.pts = None | |
| resampled_frames = resampler.resample(frame) | |
| if resampled_frames is not None: | |
| for resampled_frame in resampled_frames: | |
| for packet in output_stream.encode(resampled_frame): | |
| output_container.mux(packet) | |
| for packet in output_stream.encode(None): | |
| output_container.mux(packet) | |
| output_container.close() | |
| return resampled_file | |
| def save_to_wave(filename, data:np.ndarray, sample_rate=16000): | |
| data = (data * 32767).astype(np.int16) | |
| write(filename, sample_rate, data) | |
| def pcm_bytes_to_np_array(pcm_bytes: bytes, dtype=np.float32, channels=1): | |
| # 1. 转换成 numpy int16 数组(每个采样点是 2 字节) | |
| audio_np = np.frombuffer(pcm_bytes, dtype=np.int16) | |
| audio_np = audio_np.astype(dtype=dtype) | |
| if dtype == np.float32: | |
| audio_np /= 32768.0 | |
| # 2. 如果是多声道,例如 2 通道(立体声),你可以 reshape | |
| if channels > 1: | |
| audio_np = audio_np.reshape(-1, channels) | |
| return audio_np | |
| class TestDataWriter: | |
| def __init__(self, file_path='test_data.csv'): | |
| self.file_path = file_path | |
| self.fieldnames = [ | |
| 'seg_id', 'transcrible_time', 'translate_time', | |
| 'transcribleContent', 'from', 'to', 'translateContent', 'partial' | |
| ] | |
| self._ensure_file_has_header() | |
| def _ensure_file_has_header(self): | |
| if not os.path.exists(self.file_path) or os.path.getsize(self.file_path) == 0: | |
| with open(self.file_path, mode='w', newline='') as file: | |
| writer = csv.DictWriter(file, fieldnames=self.fieldnames) | |
| writer.writeheader() | |
| def write(self, result: 'DebugResult'): | |
| with open(self.file_path, mode='a', newline='') as file: | |
| writer = csv.DictWriter(file, fieldnames=self.fieldnames) | |
| writer.writerow(result.model_dump(by_alias=True)) |