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:9931/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:9931/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:9931/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"
david commited on
Commit ·
9bdac3d
1
Parent(s): 90a29dd
add fastapi to host websocket
Browse filesFiles changed (6)
9 unmodified lines10111213131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960619 unmodified lines </head> <body> <div id="app"></div> </body> <script> async function startRecording() { const stream = await navigator.mediaDevices.getUserMedia({ audio: true }); const audioContext = new AudioContext({ sampleRate: 16000 }); const source = audioContext.createMediaStreamSource(stream); const processor = audioContext.createScriptProcessor(4096, 1, 1);
const wsUrl = "ws://localhost:9090/ws?from=zh&to=en"; ws = new WebSocket(wsUrl);
ws.binaryType = "arraybuffer";
ws.onopen = () => { console.log("WebSocket opened"); source.connect(processor); processor.connect(audioContext.destination);
processor.onaudioprocess = (e) => { const input = e.inputBuffer.getChannelData(0); const buffer = new Int16Array(input.length); for (let i = 0; i < input.length; i++) { buffer[i] = Math.max(-1, Math.min(1, input[i])) * 0x7FFF; } ws.send(buffer); }; };
ws.onmessage = (event) => { try { const msg = JSON.parse(event.data); if (msg.result) { addTranslation(msg.result); } } catch (e) { console.error("Parse error:", e); } };
ws.onerror = (e) => console.error("WebSocket error:", e); ws.onclose = () => { console.log("WebSocket closed"); processor.disconnect(); source.disconnect(); }; } </script></body></html>12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970from fastapi import FastAPI, WebSocketfrom urllib.parse import urlparse, parse_qslfrom transcribe.whisper_llm_serve import PyWhiperCppServefrom uuid import uuid1from logging import getLoggerimport numpy as npfrom transcribe.translatepipes import TranslatePipesfrom contextlib import asynccontextmanagerfrom multiprocessing import Process, freeze_supportfrom fastapi.staticfiles import StaticFiles
logger = getLogger(__name__)
async def get_audio_from_websocket(websocket)->np.array: """ Receives audio buffer from websocket and creates a numpy array out of it.
Args: websocket: The websocket to receive audio from.
Returns: A numpy array containing the audio. """ frame_data = await websocket.receive_bytes() if frame_data == b"END_OF_AUDIO": return False return np.frombuffer(frame_data, dtype=np.int16).astype(np.float32) / 32768.0
@asynccontextmanagerasync def lifespan(app:FastAPI): global pipe pipe = TranslatePipes() pipe.wait_ready() logger.info("Pipeline is ready.") yield
app = FastAPI(lifespan=lifespan)app.mount("/translate", StaticFiles(directory="frontend"),)pipe = None
@app.websocket("/ws")async def translate(websocket: WebSocket): query_parameters_dict = websocket.query_params from_lang, to_lang = query_parameters_dict.get('from'), query_parameters_dict.get('to') client = PyWhiperCppServe( websocket, pipe, language="en", client_uid=f"{uuid1()}", )
if from_lang and to_lang: client.set_lang(from_lang, to_lang) logger.info(f"Source lange: {from_lang} -> Dst lange: {to_lang}") await websocket.accept() while True: frame_data = await get_audio_from_websocket(websocket) client.add_frames(frame_data)
if __name__ == '__main__': freeze_support() import uvicorn uvicorn.run(app, host="0.0.0.0", port=9090)17 unmodified lines1819202122232417 unmodified lines "soundfile>=0.13.1", "torch>=2.6.0", "tqdm>=4.67.1", "uvicorn>=0.34.0", "websocket-client>=1.8.0", "websockets>=15.0.1",]3 unmodified lines45677891023 unmodified lines343536373837383940413 unmodified linesimport numpy as npfrom silero_vad import get_speech_timestamps,collect_chunksimport torchimport noisereduce as nr# import noisereduce as nr
class VadPipe(BasePipe):23 unmodified lines return np.array([], dtype=np.float32)
def reduce_noise(self, data): return nr.reduce_noise(y=data, sr=self.sample_rate) # def reduce_noise(self, data): # return nr.reduce_noise(y=data, sr=self.sample_rate)
def process(self, in_data: MetaItem) -> MetaItem:123434756788 unmodified lines17181922232425262021222331242526271 unmodified line293031393233343528 unmodified lines646566746768697027 unmodified lines98991001081011021031045 unmodified lines110111112120113114115116103 unmodified lines220221222230231232233234235223224225226227228229230231
import soundfileimport multiprocessing as mpimport numpy as npfrom logging import getLogger
import asynciofrom .utils import save_to_waveimport timeimport json8 unmodified lines
logger = getLogger("TranslatorApp")
translate_pipes = TranslatePipes()translate_pipes.wait_ready()logger.info("Pipeline is ready.")
class PyWhiperCppServe(ServeClientBase): def __init__(self, websocket, language=None, dst_lang=None, client_uid=None,): def __init__(self, websocket, pipe:TranslatePipes,language=None, dst_lang=None, client_uid=None,): super().__init__(client_uid, websocket) self.language = language self.dst_lang = dst_lang # 目标翻译语言1 unmodified line self._text_buffer = TripleTextBuffer() # 存储转录数据 self._segment_manager = SegmentManager() self._translate_pipes = pipe self.lock = threading.Lock() self.frames_np = None self._frame_queue = queue.Queue()28 unmodified lines def vad_merge(self): with self.lock: frame = self.frames_np.copy() item = translate_pipes.voice_detect(frame.tobytes()) item = self._translate_pipes.voice_detect(frame.tobytes()) if item.audio != b'': frame_np = np.frombuffer(item.audio, dtype=np.float32) self.frames_np = frame_np.copy()27 unmodified lines log_block("Audio buffer length", f"{audio_buffer.shape[0]/self.sample_rate:.2f}", "s") start_time = time.perf_counter()
item = translate_pipes.transcrible(audio_buffer.tobytes(), self.language) item = self._translate_pipes.transcrible(audio_buffer.tobytes(), self.language) segments = item.segments log_block("Whisper transcrible time", f"{(time.perf_counter() - start_time):.3f}", "s") 5 unmodified lines # return "sample english" log_block("LLM translate input", f"{text}") start_time = time.perf_counter() ret = translate_pipes.translate(text, self.language, self.dst_lang) ret = self._translate_pipes.translate(text, self.language, self.dst_lang) translated_text = ret.translate_content log_block("LLM translate time", f"{(time.perf_counter() - start_time):.3f}", "s") log_block("LLM translate out", f"{translated_text}")103 unmodified lines ) def send_to_client(self, data:TransResult): try: self.websocket.send( Message(result=data, request_id=self.client_uid).model_dump_json(by_alias=True) ) except Exception as e: logger.error(f"Sending data to client: {e}") coro = self.websocket.send_text( Message(result=data, request_id=self.client_uid).model_dump_json(by_alias=True) ) asyncio.run(coro)
def get_audio_chunk_for_processing(self): if self.frames_np.shape[0] >= self.sample_rate * 1:206 unmodified lines20720820921021121221321421521621721821922022122222322465 unmodified lines290291292293294295296297298299300301302303304921 unmodified lines122612271228122912301231123213 unmodified lines124612471248124912501251125238 unmodified lines1291129212931294129512961297129812991300130113021303130413051306130713081309206 unmodified lines { url = "https://files.pythonhosted.org/packages/0e/f6/65ecc6878a89bb1c23a086ea335ad4bf21a588990c3f535a227b9eea9108/charset_normalizer-3.4.1-py3-none-any.whl", hash = "sha256:d98b1668f06378c6dbefec3b92299716b931cd4e6061f3c875a71ced1780ab85", size = 49767 },]
[[package]]name = "click"version = "8.1.8"source = { registry = "https://pypi.org/simple" }dependencies = [ { name = "colorama", marker = "sys_platform == 'win32'" },]sdist = { url = "https://files.pythonhosted.org/packages/b9/2e/0090cbf739cee7d23781ad4b89a9894a41538e4fcf4c31dcdd705b78eb8b/click-8.1.8.tar.gz", hash = "sha256:ed53c9d8990d83c2a27deae68e4ee337473f6330c040a31d4225c9574d16096a", size = 226593 }wheels = [ { url = "https://files.pythonhosted.org/packages/7e/d4/7ebdbd03970677812aac39c869717059dbb71a4cfc033ca6e5221787892c/click-8.1.8-py3-none-any.whl", hash = "sha256:63c132bbbed01578a06712a2d1f497bb62d9c1c0d329b7903a866228027263b2", size = 98188 },]
[[package]]name = "colorama"version = "0.4.6"65 unmodified lines { url = "https://files.pythonhosted.org/packages/5c/0d/24d40adaacf77f133ac87a29c045ee0d81bb99732b09b6ff0251c76e5c67/fsspec-2025.3.1-py3-none-any.whl", hash = "sha256:2ce85886f37dfa12d5ad4764f1342efbf00ec0a4fe164f070038499d80142887", size = 194444 },]
[[package]]name = "h11"version = "0.14.0"source = { registry = "https://pypi.org/simple" }sdist = { url = "https://files.pythonhosted.org/packages/f5/38/3af3d3633a34a3316095b39c8e8fb4853a28a536e55d347bd8d8e9a14b03/h11-0.14.0.tar.gz", hash = "sha256:8f19fbbe99e72420ff35c00b27a34cb9937e902a8b810e2c88300c6f0a3b699d", size = 100418 }wheels = [ { url = "https://files.pythonhosted.org/packages/95/04/ff642e65ad6b90db43e668d70ffb6736436c7ce41fcc549f4e9472234127/h11-0.14.0-py3-none-any.whl", hash = "sha256:e3fe4ac4b851c468cc8363d500db52c2ead036020723024a109d37346efaa761", size = 58259 },]
[[package]]name = "humanfriendly"version = "10.0"921 unmodified lines { name = "soundfile" }, { name = "torch" }, { name = "tqdm" }, { name = "uvicorn" }, { name = "websocket-client" }, { name = "websockets" },]13 unmodified lines { name = "soundfile", specifier = ">=0.13.1" }, { name = "torch", specifier = ">=2.6.0" }, { name = "tqdm", specifier = ">=4.67.1" }, { name = "uvicorn", specifier = ">=0.34.0" }, { name = "websocket-client", specifier = ">=1.8.0" }, { name = "websockets", specifier = ">=15.0.1" },]38 unmodified lines { url = "https://files.pythonhosted.org/packages/c8/19/4ec628951a74043532ca2cf5d97b7b14863931476d117c471e8e2b1eb39f/urllib3-2.3.0-py3-none-any.whl", hash = "sha256:1cee9ad369867bfdbbb48b7dd50374c0967a0bb7710050facf0dd6911440e3df", size = 128369 },]
[[package]]name = "uvicorn"version = "0.34.0"source = { registry = "https://pypi.org/simple" }dependencies = [ { name = "click" }, { name = "h11" },]sdist = { url = "https://files.pythonhosted.org/packages/4b/4d/938bd85e5bf2edeec766267a5015ad969730bb91e31b44021dfe8b22df6c/uvicorn-0.34.0.tar.gz", hash = "sha256:404051050cd7e905de2c9a7e61790943440b3416f49cb409f965d9dcd0fa73e9", size = 76568 }wheels = [ { url = "https://files.pythonhosted.org/packages/61/14/33a3a1352cfa71812a3a21e8c9bfb83f60b0011f5e36f2b1399d51928209/uvicorn-0.34.0-py3-none-any.whl", hash = "sha256:023dc038422502fa28a09c7a30bf2b6991512da7dcdb8fd35fe57cfc154126f4", size = 62315 },]
[[package]]name = "websocket-client"version = "1.8.0"frontend/index.html+47-1
main.py+70
pyproject.toml+1
transcribe/pipelines/pipe_vad.py+3-3
transcribe/whisper_llm_serve.py+12-19
uv.lock+36