Text-to-Speech
Transformers
ONNX
GGUF
Chinese
English
voice-dialogue
speech-recognition
large-language-model
asr
tts
llm
chinese
english
real-time
conversational
Instructions to use MoYoYoTech/VoiceDialogue with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use MoYoYoTech/VoiceDialogue with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-to-speech", model="MoYoYoTech/VoiceDialogue")# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("MoYoYoTech/VoiceDialogue", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use MoYoYoTech/VoiceDialogue 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/VoiceDialogue:Q6_K # Run inference directly in the terminal: llama cli -hf MoYoYoTech/VoiceDialogue:Q6_K
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf MoYoYoTech/VoiceDialogue:Q6_K # Run inference directly in the terminal: llama cli -hf MoYoYoTech/VoiceDialogue:Q6_K
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/VoiceDialogue:Q6_K # Run inference directly in the terminal: ./llama-cli -hf MoYoYoTech/VoiceDialogue:Q6_K
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/VoiceDialogue:Q6_K # Run inference directly in the terminal: ./build/bin/llama-cli -hf MoYoYoTech/VoiceDialogue:Q6_K
Use Docker
docker model run hf.co/MoYoYoTech/VoiceDialogue:Q6_K
- LM Studio
- Jan
- Ollama
How to use MoYoYoTech/VoiceDialogue with Ollama:
ollama run hf.co/MoYoYoTech/VoiceDialogue:Q6_K
- Unsloth Desktop
- Pi
How to use MoYoYoTech/VoiceDialogue with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf MoYoYoTech/VoiceDialogue:Q6_K
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/VoiceDialogue:Q6_K" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Docker Model Runner
How to use MoYoYoTech/VoiceDialogue with Docker Model Runner:
docker model run hf.co/MoYoYoTech/VoiceDialogue:Q6_K
- Lemonade
How to use MoYoYoTech/VoiceDialogue with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull MoYoYoTech/VoiceDialogue:Q6_K
Run and chat with the model
lemonade run user.VoiceDialogue-Q6_K
List all available models
lemonade list
- Hermes Agent
How to use MoYoYoTech/VoiceDialogue 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/VoiceDialogue:Q6_K
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/VoiceDialogue:Q6_K
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use MoYoYoTech/VoiceDialogue with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf MoYoYoTech/VoiceDialogue:Q6_K
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/VoiceDialogue:Q6_K" \ --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"
liumaolin commited on
Commit ·
92bb56d
1
Parent(s): 6f036c6
Refactor session ID handling: replace `current_session_id` with `SessionIdManager` for thread-safe management, update related imports and references.
Browse files
src/VoiceDialogue/api/routes/system_routes.py
CHANGED
|
@@ -4,6 +4,7 @@ import time
|
|
| 4 |
|
| 5 |
from fastapi import APIRouter, HTTPException, BackgroundTasks, Request
|
| 6 |
|
|
|
|
| 7 |
from ..core.service_factories import get_audio_capture_service_definition
|
| 8 |
from ..schemas.system_schemas import (
|
| 9 |
SystemStatusResponse, SystemResponse
|
|
@@ -77,6 +78,7 @@ async def start_system(
|
|
| 77 |
|
| 78 |
# 更新状态
|
| 79 |
_system_status["status"] = "starting"
|
|
|
|
| 80 |
|
| 81 |
# 在后台启动系统
|
| 82 |
background_tasks.add_task(
|
|
@@ -162,7 +164,7 @@ async def restart_system(
|
|
| 162 |
await stop_system(fastapi_request)
|
| 163 |
|
| 164 |
# 再启动
|
| 165 |
-
return await start_system(
|
| 166 |
|
| 167 |
except Exception as e:
|
| 168 |
logger.error(f"系统重启失败: {e}", exc_info=True)
|
|
|
|
| 4 |
|
| 5 |
from fastapi import APIRouter, HTTPException, BackgroundTasks, Request
|
| 6 |
|
| 7 |
+
from core.constants import session_manager
|
| 8 |
from ..core.service_factories import get_audio_capture_service_definition
|
| 9 |
from ..schemas.system_schemas import (
|
| 10 |
SystemStatusResponse, SystemResponse
|
|
|
|
| 78 |
|
| 79 |
# 更新状态
|
| 80 |
_system_status["status"] = "starting"
|
| 81 |
+
session_manager.reset_id()
|
| 82 |
|
| 83 |
# 在后台启动系统
|
| 84 |
background_tasks.add_task(
|
|
|
|
| 164 |
await stop_system(fastapi_request)
|
| 165 |
|
| 166 |
# 再启动
|
| 167 |
+
return await start_system(fastapi_request, background_tasks)
|
| 168 |
|
| 169 |
except Exception as e:
|
| 170 |
logger.error(f"系统重启失败: {e}", exc_info=True)
|
src/VoiceDialogue/core/constants.py
CHANGED
|
@@ -1,9 +1,9 @@
|
|
| 1 |
import multiprocessing
|
| 2 |
import threading
|
| 3 |
-
import uuid
|
| 4 |
from collections import OrderedDict
|
| 5 |
|
| 6 |
from utils.cache import LRUCacheDict
|
|
|
|
| 7 |
from .state_manager import VoiceStateManager
|
| 8 |
|
| 9 |
# ======================= 音频配置常量 =======================
|
|
@@ -44,7 +44,7 @@ voice_state_manager = VoiceStateManager()
|
|
| 44 |
|
| 45 |
# 会话缓存
|
| 46 |
chat_history_cache: dict[str, OrderedDict] = {}
|
| 47 |
-
|
| 48 |
dropped_audio_cache = LRUCacheDict(maxsize=50)
|
| 49 |
|
| 50 |
# ======================= 线程事件对象 =======================
|
|
|
|
| 1 |
import multiprocessing
|
| 2 |
import threading
|
|
|
|
| 3 |
from collections import OrderedDict
|
| 4 |
|
| 5 |
from utils.cache import LRUCacheDict
|
| 6 |
+
from .session_id_manager import SessionIdManager
|
| 7 |
from .state_manager import VoiceStateManager
|
| 8 |
|
| 9 |
# ======================= 音频配置常量 =======================
|
|
|
|
| 44 |
|
| 45 |
# 会话缓存
|
| 46 |
chat_history_cache: dict[str, OrderedDict] = {}
|
| 47 |
+
session_manager: SessionIdManager = SessionIdManager()
|
| 48 |
dropped_audio_cache = LRUCacheDict(maxsize=50)
|
| 49 |
|
| 50 |
# ======================= 线程事件对象 =======================
|
src/VoiceDialogue/core/session_id_manager.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import threading
|
| 2 |
+
import uuid
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
class SessionIdManager:
|
| 6 |
+
def __init__(self):
|
| 7 |
+
self._current_id: str = f'{uuid.uuid4()}'
|
| 8 |
+
self._lock = threading.Lock() # 为线程安全添加锁
|
| 9 |
+
|
| 10 |
+
def get_id(self) -> str:
|
| 11 |
+
"""获取当前的会话ID (线程安全)。"""
|
| 12 |
+
with self._lock:
|
| 13 |
+
return self._current_id
|
| 14 |
+
|
| 15 |
+
def set_id(self, new_id: str) -> None:
|
| 16 |
+
"""设置新的会话ID (线程安全)。"""
|
| 17 |
+
with self._lock:
|
| 18 |
+
self._current_id = new_id
|
| 19 |
+
|
| 20 |
+
def reset_id(self) -> str:
|
| 21 |
+
"""生成一个新的UUID作为会话ID,并更新当前ID,然后返回新的ID (线程安全)。"""
|
| 22 |
+
with self._lock:
|
| 23 |
+
self._current_id = f'{uuid.uuid4()}'
|
| 24 |
+
return self._current_id
|
| 25 |
+
|
| 26 |
+
@property
|
| 27 |
+
def current_id(self) -> str:
|
| 28 |
+
"""通过属性方式获取当前的会话ID (线程安全)。"""
|
| 29 |
+
return self.get_id()
|
| 30 |
+
|
| 31 |
+
@current_id.setter
|
| 32 |
+
def current_id(self, value: str) -> None:
|
| 33 |
+
"""通过属性方式设置新的会话ID (线程安全)。"""
|
| 34 |
+
self.set_id(value)
|
src/VoiceDialogue/services/speech/monitor.py
CHANGED
|
@@ -13,12 +13,12 @@ from queue import Empty
|
|
| 13 |
import librosa
|
| 14 |
import numpy as np
|
| 15 |
|
| 16 |
-
from models.voice_task import VoiceTask
|
| 17 |
from core.base import BaseThread
|
| 18 |
from core.constants import (
|
| 19 |
-
voice_state_manager, silence_over_threshold_event, user_still_speaking_event,
|
| 20 |
)
|
| 21 |
from core.enums import AudioState
|
|
|
|
| 22 |
|
| 23 |
|
| 24 |
class SpeechMonitorConfig:
|
|
@@ -185,7 +185,7 @@ class SpeechStateMonitor(BaseThread):
|
|
| 185 |
Returns:
|
| 186 |
VoiceTask: 创建的语音任务
|
| 187 |
"""
|
| 188 |
-
voice_task = VoiceTask(id=self.task_id, session_id=
|
| 189 |
voice_task.answer_id = f'{uuid.uuid4()}'
|
| 190 |
voice_task.user_voice = audio_frames.copy()
|
| 191 |
voice_task.send_time = time.time()
|
|
|
|
| 13 |
import librosa
|
| 14 |
import numpy as np
|
| 15 |
|
|
|
|
| 16 |
from core.base import BaseThread
|
| 17 |
from core.constants import (
|
| 18 |
+
voice_state_manager, silence_over_threshold_event, user_still_speaking_event, session_manager
|
| 19 |
)
|
| 20 |
from core.enums import AudioState
|
| 21 |
+
from models.voice_task import VoiceTask
|
| 22 |
|
| 23 |
|
| 24 |
class SpeechMonitorConfig:
|
|
|
|
| 185 |
Returns:
|
| 186 |
VoiceTask: 创建的语音任务
|
| 187 |
"""
|
| 188 |
+
voice_task = VoiceTask(id=self.task_id, session_id=session_manager.current_id)
|
| 189 |
voice_task.answer_id = f'{uuid.uuid4()}'
|
| 190 |
voice_task.user_voice = audio_frames.copy()
|
| 191 |
voice_task.send_time = time.time()
|