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 ·
fca9809
1
Parent(s): 9150655
add vad pipeline
Browse filesFiles changed (7)
123345612 unmodified lines1920212222232425from logging import getLoggerfrom llama_cpp import Llamaimport timefrom functools import lru_cache
logger = getLogger(__name__)
12 unmodified lines {"role": "user", "content": prompt}, ]
@lru_cache(maxsize=10) def translate(self, prompt, src_lang, dst_lang) -> str: message = self.to_message(prompt, src_lang, dst_lang) output = self.llm.create_chat_completion(messages=message, temperature=0)3 unmodified lines456778910111213141516171819202122232425262728293031323334353637383 unmodified linesimport onnxruntimefrom datetime import timedeltafrom pydub import AudioSegmentfrom silero_vad import load_silero_vad, get_speech_timestampsfrom silero_vad import load_silero_vad, get_speech_timestamps, VADIteratorimport osimport logging
class FixedVADIterator(VADIterator): '''It fixes VADIterator by allowing to process any audio length, not only exactly 512 frames at once. If audio to be processed at once is long and multiple voiced segments detected, then __call__ returns the start of the first segment, and end (or middle, which means no end) of the last segment. '''
def reset_states(self): super().reset_states() self.buffer = np.array([],dtype=np.float32)
def __call__(self, x, return_seconds=False): self.buffer = np.append(self.buffer, x) ret = None while len(self.buffer) >= 512: r = super().__call__(self.buffer[:512], return_seconds=return_seconds) self.buffer = self.buffer[512:] if ret is None: ret = r elif r is not None: if 'end' in r: ret['end'] = r['end'] # the latter end if 'start' in r and 'end' in ret: # there is an earlier start. # Remove end, merging this segment with the previous one. del ret['end'] return ret if ret != {} else None
class SileroVADProcessor: """1 unmodified line23456789101145 unmodified lines5758596061626364651 unmodified linefrom dataclasses import dataclass, fieldfrom multiprocessing import Process, Queuefrom multiprocessing import Eventfrom logging import getLogger
logger = getLogger(__name__)
@dataclassclass Segment:45 unmodified lines raise NotImplementedError
def run(self): logger.info(f"start initial {self.__class__.__name__}") self.init() logger.info(f"finish initial {self.__class__.__name__}") self.set_ready() while True: item = self.input_queue.get()12334556789101110121314151617185 unmodified lines2425262728293031323334353625262737383940414243323334353637383940414243444546474849505152535455565758596061626364656667444546474849506951
from .base import MetaItem, BasePipefrom ..helpers.vadprocessor import SileroVADProcessorfrom ..helpers.vadprocessor import SileroVADProcessor, FixedVADIteratorimport numpy as npfrom silero_vad import read_audio, get_speech_timestamps,collect_chunks, VADIteratorfrom silero_vad import get_speech_timestamps,collect_chunksimport torchimport noisereduce as nr
class VadPipe(BasePipe): model = None sample_rate=16000 sample_rate = 16000 window_size_samples = 512
@classmethod def init(cls): if cls.model is None:5 unmodified lines min_silence_duration=250, sample_rate=cls.sample_rate ) cls.vac = FixedVADIterator(cls.model.silero_vad, sampling_rate=cls.sample_rate,) cls.vac.reset_states() def get_previous_buffer(self): if len(self.previous_buffer) == 2: return self.previous_buffer[-1] return np.array([], dtype=np.float32)
@property def vad_iterator(self): return VADIterator(self.model.silero_vad, sampling_rate=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: source_audio = in_data.source_audio source_audio = np.frombuffer(source_audio, dtype=np.float32) speech_segments = [] is_speech_active = False # current_segment_end = len(source_audio) for i in range(0, len(source_audio), self.window_size_samples):
window = source_audio[i:i+self.window_size_samples] if len(window) < self.window_size_samples: padded_window = np.zeros(self.window_size_samples, dtype=np.float32) padded_window[:len(window)] = window window = padded_window
speech_dict = self.vad_iterator(window, return_seconds=False) if not speech_dict: continue # 计算当前偏移量
if speech_dict and 'start' in speech_dict and not is_speech_active: is_speech_active = True # current_segment_start = speech_dict['start'] + i if is_speech_active: speech_segments.append(window) # # 如果检测到语音结束 # if speech_dict and 'end' in speech_dict and is_speech_active: # # 调整语音结束时间,加上窗口偏移 # current_segment_end = min(speech_dict['end'] + i, current_segment_end) # is_speech_active = False # speech_audio = source_audio[current_segment_start: current_segment_end] # speech_segments.append(speech_audio)
self.vad_iterator.reset_states() combied_audio = np.concatenate(speech_segments, axis=0).tobytes() if len(speech_segments) else b"" in_data.audio = combied_audio send_audio = b"" speech_timestamps = get_speech_timestamps(source_audio, self.model.silero_vad, sampling_rate=16000) if speech_timestamps: send_audio = collect_chunks(speech_timestamps, torch.Tensor(source_audio)) send_audio = send_audio.numpy() # send_audio = self.reduce_noise(send_audio).tobytes() in_data.source_audio = b"" return in_data6 unmodified lines7891011121011126 unmodified linesclass WhisperPipe(BasePipe): whisper = None
def __init__(self, in_queue=None, out_queue=None) -> None: super().__init__(in_queue, out_queue)
@classmethod def init(cls):97 unmodified lines98991001011011021031049 unmodified lines11411511611711711811912012112212312412412512612712812712812913013197 unmodified lines
for seg in segments: temp_seq.append(seg) if any([mk in seg.text for mk in config.SENTENCE_END_MARKERS]): if any([mk in seg.text for mk in config.SENTENCE_END_MARKERS + config.PAUSE_END_MARKERS]): sequences.append(temp_seq.copy()) temp_seq = [] if temp_seq:9 unmodified lines
if (len(audio_buffer) / sample_rate) < 12: # 低于12s 使用短句符号比如逗号作为判断依据 markers = config.PAUSE_END_MARKERS markers = config.PAUSE_END_MARKERS + config.SENTENCE_END_MARKERS is_end = False
for idx, seg in enumerate(segments): left_watch_sequences.append(seg) if seg.text in markers: seg_index = int(seg.t1 / 100 * sample_rate) rest_buffer_duration = (len(audio_buffer) - seg_index) / sample_rate # rest_buffer_duration = (len(audio_buffer) - seg_index) / sample_rate # is_end = any(i in seg.text for i in config.SENTENCE_END_MARKERS) right_watch_sequences = segments[min(idx+1, len(segments)):] if rest_buffer_duration >= 1.5: left_watch_idx = seg_index # if rest_buffer_duration >= 1.5: left_watch_idx = seg_index break return left_watch_idx, left_watch_sequences, right_watch_sequences, is_end
39 unmodified lines4041424343444522 unmodified lines68697072737475717273747576777879808182838182838485868788898485863 unmodified lines90919299939495141 unmodified lines23723823924024124224339 unmodified lines self.lock = threading.Lock() self.frames_np = None self._frame_queue = queue.Queue() self._previous_frame_queue = collections.deque(maxlen=2) self.sample_rate = 16000 self.send_ready_state()22 unmodified lines def add_frames(self, frame_np): self._frame_queue.put(frame_np)
def get_prev_frame(self, ): if len(self._previous_frame_queue) == 2: return self._previous_frame_queue[-1]
def vad_merge(self): with self.lock: frame = self.frames_np.copy() item = 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() def get_frame_from_queue(self,): while True: try: frame_np = self._frame_queue.get(timeout=0.1) # frame_np = item.source_audio # self._previous_frame_queue.appendleft(frame_np.copy()) # prev_frame_np = self.get_prev_frame() # if prev_frame_np is not None: # frame_np = np.concatenate([prev_frame_np[int(-0.05 * self.sample_rate):],frame_np], axis=0) # item = translate_pipes.voice_detect(frame_np.tobytes()) # if item.audio == b"": # continue # frame_np = np.frombuffer(item.audio, dtype=np.float32) with self.lock: if self.frames_np is None: self.frames_np = frame_np.copy()3 unmodified lines pass
def update_audio_buffer(self, last_offset): with self.lock: self.frames_np = self.frames_np[last_offset:]141 unmodified lines def get_audio_chunk_for_processing(self): if self.frames_np.shape[0] >= self.sample_rate * 1: return self.frames_np.copy() self.vad_merge() # 计算需要填充的样本数 padding_length = self.sample_rate * 1 - len(self.frames_np) # 创建静音填充(零值)transcribe/helpers/translator.py+2-2
transcribe/helpers/vadprocessor.py+26-1
transcribe/pipelines/base.py+6
transcribe/pipelines/pipe_vad.py+24-43
transcribe/pipelines/pipe_whisper.py-3
transcribe/strategy.py+5-5
transcribe/whisper_llm_serve.py+9-15