Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# vibevoice_tts_websocket_python

TEN TTS extension for ezai_tw_tts_python.

## Quick start


1. Add the extension to your TEN app manifest and graph:

- Manifest dependency:
- `../../../ten_packages/extension/ezai_tw_tts_python`
-- Graph node:

```json
{
"type": "extension",
"name": "tts",
"addon": "ezai_tw_tts_python",
"extension_group": "tts",
"property": {
"dump": false,
"dump_path": "./",
"params": {
"speed": 0.8,
"denoise": false,
"voice": "",
"zh_model": "",
}
}
}
```

1. Run your TEN app as usual..

## Configuration

- `params.url`: websocket endpoint (default `ws://127.0.0.1:3000/stream`)
- `params.speed`: text-to-speech speed/power (default 0.8)
- `params.denoise`: whether to apply denoising (default false)
- `params.voice`: voice preset key (optional)
- `params.zh_model`: chinese translation model to use (optional)
- `sample_rate`, `channels`, `sample_width`: PCM properties consumed/produced by TTS (defaults: 24000, 1, 2)
- `dump`: write PCM to disk for debugging
- `dump_path`: directory for dump files
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#
# This file is part of TEN Framework, an open source project.
# Licensed under the Apache License, Version 2.0.
# See the LICENSE file for more information.
#
from . import addon
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#
# This file is part of TEN Framework, an open source project.
# Licensed under the Apache License, Version 2.0.
# See the LICENSE file for more information.
#
from ten_runtime import Addon, TenEnv, register_addon_as_extension


@register_addon_as_extension("ezai_tw_tts_python")
class EZAITWTTSExtensionAddon(Addon):
def on_create_instance(self, ten_env: TenEnv, name: str, context) -> None:
from .extension import EZAITWTTSExtension

ten_env.log_info("EZAITWTTSExtensionAddon on_create_instance")
ten_env.on_create_instance_done(EZAITWTTSExtension(name), context)
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
from typing import Any, Dict

from pydantic import BaseModel, Field


class EZAITWTTSConfig(BaseModel):
url: str = "https://matcha.ezai-k8s.freeddns.org/tts"
voice: str = "IU_IUF1003"
denoise: bool = True
zh_model: str = "nllb"
sample_rate: int = 24000
channels: int = 1
sample_width: int = 2
dump: bool = False
dump_path: str = ""
params: Dict[str, Any] = Field(default_factory=dict)

def update_params(self) -> None:
if "url" in self.params:
self.url = str(self.params["url"])
del self.params["url"]

if "voice" in self.params:
voice_val = self.params["voice"]
del self.params["voice"]
self.voice = str(voice_val) if voice_val else ""

if "sample_rate" in self.params:
try:
self.sample_rate = int(self.params["sample_rate"])
del self.params["sample_rate"]
except (TypeError, ValueError):
del self.params["sample_rate"]

if "channels" in self.params:
try:
self.channels = int(self.params["channels"])
del self.params["channels"]
except (TypeError, ValueError):
del self.params["channels"]

if "sample_width" in self.params:
try:
self.sample_width = int(self.params["sample_width"])
del self.params["sample_width"]
except (TypeError, ValueError):
del self.params["sample_width"]

def to_str(self) -> str:
return f"{self}"
Loading
Loading