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"
daihui.zhang commited on
Commit ·
ebbd5df
1
Parent(s): 716f8d1
update config of language
Browse filesFormer-commit-id: 6c237bee605ec8fe2e28517a2d7e0a385747ab5b
Files changed (6)
6 unmodified lines78910111213141516176 unmodified linesdependencies = [ "av>=14.2.0", "librosa>=0.11.0", "llama-cpp-python>=0.3.8", "numpy>=2.1.3", "onnxruntime>=1.21.0", "pyaudio>=0.2.14", "pywhispercpp>=1.3.0", "setuptools>=78.1.0", "soundfile>=0.13.1", "torch>=2.6.0",13 unmodified lines14151617181920215 unmodified lines272829283031323334352 unmodified lines383940414243444510 unmodified lines565758596061626364656 unmodified lines727374677576777879802 unmodified lines8384858687887789909192939417 unmodified lines1121131141151011161171181191201211221231241 unmodified line12612712811211311413 unmodified lines # via onnxruntimedecorator==5.2.1 # via librosadiskcache==5.6.3 # via llama-cpp-pythonfilelock==3.18.0 # via torchflatbuffers==25.2.105 unmodified linesidna==3.10 # via requestsjinja2==3.1.6 # via torch # via # llama-cpp-python # torchjoblib==1.4.2 # via # librosa2 unmodified lines # via librosalibrosa==0.11.0 # via trans (pyproject.toml)llama-cpp-python==0.3.8 # via trans (pyproject.toml)llvmlite==0.44.0 # via numbamarkupsafe==3.0.210 unmodified lines # via # trans (pyproject.toml) # librosa # llama-cpp-python # numba # onnxruntime # pywhispercpp # scikit-learn # scipy # soundfile6 unmodified lines # onnxruntime # poochplatformdirs==4.3.7 # via pooch # via # pooch # pywhispercpppooch==1.8.2 # via librosaprotobuf==6.30.22 unmodified lines # via trans (pyproject.toml)pycparser==2.22 # via cffipywhispercpp==1.3.0 # via trans (pyproject.toml)requests==2.32.3 # via pooch # via # pooch # pywhispercppscikit-learn==1.6.1 # via librosascipy==1.15.217 unmodified linestorch==2.6.0 # via trans (pyproject.toml)tqdm==4.67.1 # via # via trans (pyproject.toml) # trans (pyproject.toml) # pywhispercpptyping-extensions==4.13.1 # via # librosa # llama-cpp-python # torchurllib3==2.3.0 # via requests1 unmodified line # via trans (pyproject.toml)websockets==15.0.1 # via trans (pyproject.toml)
llama-cpp-pythonpywhispercpp21 unmodified lines222324252526272821 unmodified lines if "OMP_NUM_THREADS" not in os.environ: os.environ["OMP_NUM_THREADS"] = str(args.omp_num_threads)
from transcribe.server import TranscriptionServer from transcribe.transcription import TranscriptionServer server = TranscriptionServer() server.run( "0.0.0.0",10 unmodified lines1112131414151617189 unmodified lines2829303031313233333435363710 unmodified lines # n_gpu_layers=-1, # Uncomment to use GPU acceleration # seed=1337, # Uncomment to set a specific seed # n_ctx=2048, # Uncomment to increase the context window chat_format="chatml" chat_format="chatml", verbose=False) self.sys_prompt = system_prompt
9 unmodified lines message = self.to_message(prompt, src_lang, dst_lang) start_time = time.monotonic() output = self.llm.create_chat_completion(messages=message, temperature=0.9) logger.info(f"LLM translate cose: {time.monotonic() - start_time}s.") return output['choices'][0]['content'] logger.info(f"LLM translate cose: {time.monotonic() - start_time:.2f}s.") return output['choices'][0]['message']['content'] def __call__(self, prompt, max_tokens=256,*args, **kwargs): def __call__(self, prompt, max_tokens=512,*args, **kwargs): return self.llm( prompt, *args,12323455 unmodified lines11121314151617151819202183 unmodified lines1051061071051061081091101111121131111141151161172 unmodified lines1201211221231241251261271281291301251311321331347 unmodified lines1421431441391451461471481 unmodified line1501511521531541551561571581591601511611621631641651661675 unmodified lines17317417516517617717817918018121 unmodified lines20320420519420620719620820921021121221321421521621721821922064 unmodified lines28528628726728828929029129212 unmodified lines3053063072862872882893083093103113121 unmodified line314315316297317318319320
from .server import ServeClientBasefrom pywhispercpp.model import Model
import soundfilefrom concurrent.futures import ProcessPoolExecutor as Poolimport numpy as np5 unmodified linesimport jsonimport threading
from .server import ServeClientBasefrom .translator import QwenTranslatorfrom pywhispercpp.model import Model
logger = getLogger("Pywhisper")logger = getLogger(__name__)
class TripleTextBuffer:83 unmodified lines
class PywhisperInference:
model = None whisper_model = None llm_model = None
@classmethod def initializer(cls, warmup=True): models_dir = config.MODEL_DIR.as_posix() cls.model = Model( cls.whisper_model = Model( model=config.WHISPER_MODEL, models_dir=models_dir, print_realtime=False,2 unmodified lines ) if warmup: cls.warmup() # init llamacpp cls.llm_model = QwenTranslator(config.LLM_MODEL_PATH, config.LLM_SYS_PROMPT) @classmethod def warmup(cls, warmup_steps=1): mel, _, = soundfile.read("assets/jfk.flac") for _ in range(warmup_steps): cls.model.transcribe(mel, print_progress=False) cls.whisper_model.transcribe(mel, print_progress=False)
@staticmethod def config_language(language):7 unmodified lines def inference(cls, audio_buffer, language): max_len, prompt = cls.config_language(language) audio_buffer = np.frombuffer(audio_buffer, dtype=np.float32) return cls.model.transcribe( return cls.whisper_model.transcribe( audio_buffer, initial_prompt=prompt, language=language, 1 unmodified line max_len=max_len ) @classmethod def translate(cls, context: str, src_lang, dst_lang): return cls.llm_model.translate(context, src_lang, dst_lang)
class PyWhiperCppServe(ServeClientBase): def __init__(self, websocket, language=None, client_uid=None,): def __init__(self, websocket, language=None, dst_lang=None, client_uid=None,): super().__init__(client_uid, websocket) self.language = language self.dst_lang = dst_lang # 目标翻译语言 # 设置观察字符串 对比上下次的文字来判断字符串的输出是否固定 self._text_buffer = TripleTextBuffer() # 存储转录数据5 unmodified lines self._pool = Pool( max_workers=1, initializer=PywhisperInference.initializer)
logger.info('Create a thread to process audio.') logger.info('Create a process to process audio.') self.trans_thread = threading.Thread(target=self.speech_to_text) self.trans_thread.daemon = True self.trans_thread.start()
self.websocket.send(json.dumps({21 unmodified lines Args: audio_buffer (np.array): The audio chunk to transcribe. """ fut = self._pool.submit( transcribe_fut = self._pool.submit( PywhisperInference.inference, audio_buffer.tobytes(), self.language) return fut.result() segments = transcribe_fut.result() return segments def translate_text(self, text): """ translate the text to dst lang""" translate_fut = self._pool.submit( PywhisperInference.translate, text, self.language, self.dst_lang) return translate_fut.result()
64 unmodified lines except Exception as e: logger.error(f"[ERROR]: {e}") else: self.handle_transcription_output(segments, audio_buffer) for item in self.handle_transcription_output(segments, audio_buffer): print(item) 12 unmodified lines if is_end_sentence and last_cut_index: message = self._segment_manager.segment seg_id = self._segment_manager.get_seg_id() - 1 # elapsed_time = time.time() - start_time # formatted_time = f"{int(elapsed_time // 60):02}:{int(elapsed_time % 60):02}:{(elapsed_time % 1) * 1000:03.0f}" print(seg_id, message,) print(seg_id + 1, self._segment_manager.string,) yield (seg_id, message, self.translate_text(message)) yield (seg_id + 1, self._segment_manager.string, self.translate_text(self._segment_manager.string)) else: seg_id = self._segment_manager.get_seg_id()1 unmodified line # print(self._segment_manager.__dict__) # elapsed_time = time.time() - start_time # formatted_time = f"{int(elapsed_time // 60):02}:{int(elapsed_time % 60):02}:{(elapsed_time % 1) * 1000:03.0f}" print(seg_id, message) yield (seg_id, message,self.translate_text(message)) def send_to_client(self, data_dict): content = {213 unmodified lines214215216217218219220221222223224225226227228101 unmodified lines330331332333334335336337338339340341342343344345346347424 unmodified lines772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808254 unmodified lines106310641065106610671068106910701071107210736 unmodified lines10801081108210831084108510861087108810891090213 unmodified lines { url = "https://files.pythonhosted.org/packages/4e/8c/f3147f5c4b73e7550fe5f9352eaa956ae838d5c51eb58e7a25b9f3e2643b/decorator-5.2.1-py3-none-any.whl", hash = "sha256:d316bb415a2d9e2d2b3abcc4084c6502fc09240e292cd76a76afc106a1c8e04a", size = 9190 },]
[[package]]name = "diskcache"version = "5.6.3"source = { registry = "https://pypi.org/simple" }sdist = { url = "https://files.pythonhosted.org/packages/3f/21/1c1ffc1a039ddcc459db43cc108658f32c57d271d7289a2794e401d0fdb6/diskcache-5.6.3.tar.gz", hash = "sha256:2c3a3fa2743d8535d832ec61c2054a1641f41775aa7c556758a109941e33e4fc", size = 67916 }wheels = [ { url = "https://files.pythonhosted.org/packages/3f/27/4570e78fc0bf5ea0ca45eb1de3818a23787af9b390c0b0a0033a1b8236f9/diskcache-5.6.3-py3-none-any.whl", hash = "sha256:5e31b2d5fbad117cc363ebaf6b689474db18a1f6438bc82358b024abd4c2ca19", size = 45550 },]
[[package]]name = "filelock"version = "3.18.0"101 unmodified lines { url = "https://files.pythonhosted.org/packages/b5/ba/c63c5786dfee4c3417094c4b00966e61e4a63efecee22cb7b4c0387dda83/librosa-0.11.0-py3-none-any.whl", hash = "sha256:0b6415c4fd68bff4c29288abe67c6d80b587e0e1e2cfb0aad23e4559504a7fa1", size = 260749 },]
[[package]]name = "llama-cpp-python"version = "0.3.8"source = { registry = "https://pypi.org/simple" }dependencies = [ { name = "diskcache" }, { name = "jinja2" }, { name = "numpy" }, { name = "typing-extensions" },]sdist = { url = "https://files.pythonhosted.org/packages/95/4e/da912ff2bf9bf855c86e8b1ae9fe1eaedf47d75a66728896b533901c4610/llama_cpp_python-0.3.8.tar.gz", hash = "sha256:31c91323b555c025a76a30923cead9f5695da103dd68c15cdbb4509b17f0ed77", size = 67301056 }
[[package]]name = "llvmlite"version = "0.44.0"424 unmodified lines { url = "https://files.pythonhosted.org/packages/5a/dc/491b7661614ab97483abf2056be1deee4dc2490ecbf7bff9ab5cdbac86e1/pyreadline3-3.5.4-py3-none-any.whl", hash = "sha256:eaf8e6cc3c49bcccf145fc6067ba8643d1df34d604a1ec0eccbf7a18e6d3fae6", size = 83178 },]
[[package]]name = "pywhispercpp"version = "1.3.0"source = { registry = "https://pypi.org/simple" }dependencies = [ { name = "numpy" }, { name = "platformdirs" }, { name = "requests" }, { name = "tqdm" },]sdist = { url = "https://files.pythonhosted.org/packages/85/bf/213ab706513a2ad6f0266b44c841f5123ae3592e769488be1e62268f0451/pywhispercpp-1.3.0.tar.gz", hash = "sha256:d5d4ddfdbe7472736343413355f47a74783bc40891c5826b607eac4f62b08279", size = 1580900 }wheels = [ { url = "https://files.pythonhosted.org/packages/79/4d/4765b2477e028d27f0f497f9e7e27ecfd207cf1d133c12626a7901ceca8a/pywhispercpp-1.3.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:f66cc5ff624744cf0b7da1c53d67d2e3416f92a02c7ae945697d47d13eed5845", size = 1562728 }, { url = "https://files.pythonhosted.org/packages/e5/0d/a17a403feeea0e0d064fb230d56119718ca813d6b382804848c387387022/pywhispercpp-1.3.0-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:b2fb92868fb7219478f6bdff50d5045583466985e3e9017af040735eb650772d", size = 1893935 }, { url = "https://files.pythonhosted.org/packages/3f/09/db14ce3c4555a642ba62e4da226e578ea86d1c32ca70b93e32dae3309cf2/pywhispercpp-1.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:66270fb0dbb00745419001eef7c46c49e2104b80ebd21d8e65d58f0bdef7c2a7", size = 1788858 }, { url = "https://files.pythonhosted.org/packages/a0/28/fd4de678cfc50ad8dedba1ab5f9a3e3563759ca3dce273eb2b09b95e4729/pywhispercpp-1.3.0-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:f61f2e36f06bb98cd139aee073d6af5223fe551bab80ce3cbdc643eb7edb5e1b", size = 3026209 }, { url = "https://files.pythonhosted.org/packages/94/a3/81c3616eb033344e4af356896aded58c1f36fdca253294dd501db7630a09/pywhispercpp-1.3.0-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:bf0478a443ea7a56f35fbeba1c5f1988b13088aafc79d533a67020ee7ce146f3", size = 2792276 }, { url = "https://files.pythonhosted.org/packages/49/83/0bcb864c5dff802afd4c1887149bf029ea6715e20438feb0eb0727e0e70d/pywhispercpp-1.3.0-cp311-cp311-win32.whl", hash = "sha256:0c906e7537d9e81813d86bcc98824085058174b238900bad655c8d7bd426f9a4", size = 731243 }, { url = "https://files.pythonhosted.org/packages/a7/15/5421c0814e611aae9f1541c36d4bfba157ae30580424091519aaeffe3f1d/pywhispercpp-1.3.0-cp311-cp311-win_amd64.whl", hash = "sha256:3af25987a0d3caa88a6c795b2e0051b74515a81c33bdbd49c6e8ca65b7fdc6db", size = 863874 }, { url = "https://files.pythonhosted.org/packages/4b/e6/c4008fed98e0ab047bd458aaeb675226d2bd630c11939e641c3385657552/pywhispercpp-1.3.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:dd0903d9685447700ed4cad48f298cb73dd073bcd0abb8bcf974646006f4e222", size = 1563954 }, { url = "https://files.pythonhosted.org/packages/d9/31/5de448da80b8e58bda47e2ca503b97484afafe93d93793f5f7b6140f9fba/pywhispercpp-1.3.0-cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:e84926618d819aaeb128170351b7489dc01cabb0e58c44c6b11f8449f0850d7a", size = 1893782 }, { url = "https://files.pythonhosted.org/packages/5c/82/cb38ffa05a0fcbff7547a42735b05f36d92af5352ae7273764e05ca85363/pywhispercpp-1.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2ba675b98ffd1901d3696613655700d3d407bd952e110a1bfbbb618997818d8b", size = 1787927 }, { url = "https://files.pythonhosted.org/packages/90/9d/3aa981b0551d44339ffc613c4466df4d8e3c59609da444a490eac032e0a2/pywhispercpp-1.3.0-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:2b8407a9cae5555bd276fac578155de6273f3bcc0ee8960c1fd0cfb7f4be1be9", size = 3027385 }, { url = "https://files.pythonhosted.org/packages/b0/3f/85924b54772e5ce5222bbf9aa98247800c7be2262daf17d07e2fae6e1ced/pywhispercpp-1.3.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:fd31fa0992a39e55d4a793dad1f6d2a1a97261998d52726f4568cea0af78ff93", size = 2791659 }, { url = "https://files.pythonhosted.org/packages/71/63/0ed9a4a776d81018536f2e5556fe364599a661aeded42627f93e1d4282aa/pywhispercpp-1.3.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:e8d1b339409668382f68b810c2ccac010e71d580c6afe6d67e86336daeb939ed", size = 1563943 }, { url = "https://files.pythonhosted.org/packages/e4/3b/f9fda6bd691900e76702945405919174838497096961f56aa8583b6373ed/pywhispercpp-1.3.0-cp313-cp313-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:0ac9fea9e3aeb5219ce614f644c4f1b38b9561eede1e4380ab39de96afba8864", size = 1893777 }, { url = "https://files.pythonhosted.org/packages/42/fc/26b0811b3964f4b14691ff28d84ccfd5fb7b800eab7ca898f538271c9c61/pywhispercpp-1.3.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:fc6801332deb2d6efc67e5dd7c9c9b1ce06f8235270b3ebd5546a79040a67314", size = 1787957 }, { url = "https://files.pythonhosted.org/packages/3a/f2/1673b43721246a9da0a9820abb6aa442c4de0129d2039fd107f0657878f4/pywhispercpp-1.3.0-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:5bc5742787037f421f748ad463d85bce565287e77dfddaa5536d37d59ac44267", size = 3027419 }, { url = "https://files.pythonhosted.org/packages/d2/33/292a727bd3aa826c5981df32ce228f3e89edf4116ae4cc9d76ddedb9fb07/pywhispercpp-1.3.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:a6f7578fb9a8de4c8663323060c0715713168ae174ab022dfe9ad13b21223c3c", size = 2791670 },]
[[package]]name = "requests"version = "2.32.3"254 unmodified linesdependencies = [ { name = "av" }, { name = "librosa" }, { name = "llama-cpp-python" }, { name = "numpy" }, { name = "onnxruntime" }, { name = "pyaudio" }, { name = "pywhispercpp" }, { name = "setuptools" }, { name = "soundfile" }, { name = "torch" },6 unmodified linesrequires-dist = [ { name = "av", specifier = ">=14.2.0" }, { name = "librosa", specifier = ">=0.11.0" }, { name = "llama-cpp-python", specifier = ">=0.3.8" }, { name = "numpy", specifier = ">=2.1.3" }, { name = "onnxruntime", specifier = ">=1.21.0" }, { name = "pyaudio", specifier = ">=0.2.14" }, { name = "pywhispercpp", specifier = ">=1.3.0" }, { name = "setuptools", specifier = ">=78.1.0" }, { name = "soundfile", specifier = ">=0.13.1" }, { name = "torch", specifier = ">=2.6.0" },pyproject.toml+2
requirements.txt+21-7
run_server.py+1-1
transcribe/translate.py → transcribe/translator.pyRenamed+5-4
transcribe/whisper_llm_serve.py+38-18
uv.lock+56