Spaces:
Running
on
Zero
Running
on
Zero
add images
Browse files- README.md +69 -2
- app.py +82 -18
- imgs/0.webp +0 -0
- imgs/1.webp +0 -0
- imgs/2.webp +0 -0
- imgs/3.webp +0 -0
- imgs/4.webp +0 -0
- imgs/5.webp +0 -0
README.md
CHANGED
|
@@ -8,7 +8,74 @@ sdk_version: 6.2.0
|
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
license: mit
|
| 11 |
-
short_description: TTS voice for AI (
|
| 12 |
---
|
| 13 |
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
license: mit
|
| 11 |
+
short_description: TTS voice for AI (Currently Matcha-TTS)
|
| 12 |
---
|
| 13 |
|
| 14 |
+
# AIGamingVoice - Japanese / 日本語
|
| 15 |
+
|
| 16 |
+
High-quality, lightweight Japanese Text-to-Speech specifically tuned for AI gaming characters.
|
| 17 |
+
Running on ONNX Runtime for fast inference
|
| 18 |
+
|
| 19 |
+
AIゲームキャラクター向けに調整された高品質・軽量な日本語音声合成システムです。
|
| 20 |
+
ONNX Runtime上で動作します。
|
| 21 |
+
|
| 22 |
+
## 🌟 Features / 特徴
|
| 23 |
+
|
| 24 |
+
- **⚡ Fast & Lightweight**: Pure ONNX Runtime implementation
|
| 25 |
+
- **高速・軽量**: 純粋なONNX Runtime実装です。
|
| 26 |
+
- **🖼️ Visual Speaker Selection**: Select speakers intuitively from an image gallery.
|
| 27 |
+
- **視覚的な話者選択**: 画像ギャラリーから直感的にキャラクター(話者)を選択できます。
|
| 28 |
+
- **🇯🇵 Japanese Optimization**: Uses `pyopenjtalk` for accurate Japanese phoneme generation.
|
| 29 |
+
- **日本語最適化**: `pyopenjtalk` を使用し、正確な日本語読み上げを実現しています。
|
| 30 |
+
|
| 31 |
+
## 🛠️ Installation & Local Usage / インストールとローカルでの使用方法
|
| 32 |
+
|
| 33 |
+
1. **Clone the repository / リポジトリをクローン**
|
| 34 |
+
```bash
|
| 35 |
+
git clone https://huggingface.co/spaces/YOUR_USERNAME/AIGamingVoice-Japanese
|
| 36 |
+
cd AIGamingVoice-Japanese
|
| 37 |
+
```
|
| 38 |
+
|
| 39 |
+
2. **Install dependencies / 依存関係のインストール**
|
| 40 |
+
```bash
|
| 41 |
+
pip install -r requirements.txt
|
| 42 |
+
```
|
| 43 |
+
*Note: You need `cmake` installed for pyopenjtalk.*
|
| 44 |
+
*注: pyopenjtalkのインストールには `cmake` が必要です。*
|
| 45 |
+
|
| 46 |
+
3. **Prepare Models / モデルの準備**
|
| 47 |
+
Place your `.onnx` models in the `models/` directory.
|
| 48 |
+
`models/` ディレクトリに `.onnx` モデルファイルを配置してください。
|
| 49 |
+
|
| 50 |
+
4. **Prepare Speaker Images (Optional) / 話者画像の準備(オプション)**
|
| 51 |
+
Place images (`0.jpg`, `1.jpg`, ...) in the `imgs/` directory to enable the visual selector.
|
| 52 |
+
`imgs/` ディレクトリに画像ファイル(`0.jpg`, `1.jpg` ...)を配置すると、画像による話者選択機能が有効になります。
|
| 53 |
+
|
| 54 |
+
5. **Run the application / アプリケーションの実行**
|
| 55 |
+
```bash
|
| 56 |
+
python app.py
|
| 57 |
+
```
|
| 58 |
+
Access http://localhost:7860 in your browser.
|
| 59 |
+
ブラウザで http://localhost:7860 にアクセスしてください。
|
| 60 |
+
|
| 61 |
+
## 🎮 How to Use / 使い方
|
| 62 |
+
|
| 63 |
+
1. **Select Model**: Choose a voice model from the dropdown.
|
| 64 |
+
- **モデル選択**: ドロップダウンから音声モデルを選択します。
|
| 65 |
+
2. **Select Speaker**: Click on a character image or enter the Speaker ID.
|
| 66 |
+
- **話者選択**: キャラクター画像をクリックするか、Speaker IDを入力します。
|
| 67 |
+
3. **Input Text**: Enter Japanese text to synthesize.
|
| 68 |
+
- **テキスト入力**: 読み上げたい日本語テキストを入力します。
|
| 69 |
+
4. **Adjust Settings**: Tweak Temperature (randomness) and Speaking Rate (speed).
|
| 70 |
+
- **設定調整**: Temperature(ランダム性)やSpeaking Rate(話速)を調整できます。
|
| 71 |
+
5. **Synthesize**: Click the button to generate audio.
|
| 72 |
+
- **音声生成**: ボタンをクリックして音声を生成します。
|
| 73 |
+
|
| 74 |
+
## 🤝 Credits / クレジット
|
| 75 |
+
|
| 76 |
+
- **Matcha-TTS**: Architecture based on Matcha-TTS.
|
| 77 |
+
- **ONNX Runtime**: Inference engine.
|
| 78 |
+
- **pyopenjtalk**: Japanese text processing frontend.
|
| 79 |
+
|
| 80 |
+
---
|
| 81 |
+
*Created for AI Gaming Voice Project*
|
app.py
CHANGED
|
@@ -319,14 +319,25 @@ def create_gradio_interface():
|
|
| 319 |
# Get available models
|
| 320 |
available_models = get_available_models()
|
| 321 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 322 |
with gr.Blocks(
|
| 323 |
-
title="
|
| 324 |
) as demo:
|
| 325 |
gr.Markdown(
|
| 326 |
"""
|
| 327 |
-
# 🍵 Matcha-TTS ONNX
|
| 328 |
|
| 329 |
-
###
|
|
|
|
|
|
|
| 330 |
"""
|
| 331 |
)
|
| 332 |
|
|
@@ -347,6 +358,22 @@ def create_gradio_interface():
|
|
| 347 |
placeholder="日本語のテキストを入力してください..."
|
| 348 |
)
|
| 349 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 350 |
# Speaker ID
|
| 351 |
speaker_id = gr.Number(
|
| 352 |
label="Speaker ID (スピーカーID)",
|
|
@@ -354,7 +381,7 @@ def create_gradio_interface():
|
|
| 354 |
minimum=0,
|
| 355 |
maximum=99,
|
| 356 |
precision=0,
|
| 357 |
-
info="
|
| 358 |
)
|
| 359 |
|
| 360 |
with gr.Row():
|
|
@@ -403,15 +430,35 @@ def create_gradio_interface():
|
|
| 403 |
gr.Examples(
|
| 404 |
examples=[
|
| 405 |
["こんにちは、世界!", "g003_ep5709.onnx", 0, 0.667, 1.0],
|
| 406 |
-
["
|
| 407 |
-
["
|
| 408 |
-
["
|
|
|
|
|
|
|
|
|
|
|
|
|
| 409 |
],
|
| 410 |
inputs=[text_input, model_dropdown, speaker_id, temperature, speaking_rate],
|
| 411 |
label="例文 / Examples"
|
| 412 |
)
|
| 413 |
|
| 414 |
# Event handlers
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 415 |
synthesise_btn.click(
|
| 416 |
fn=synthesise,
|
| 417 |
inputs=[text_input, model_dropdown, speaker_id, temperature, speaking_rate],
|
|
@@ -426,18 +473,35 @@ def create_gradio_interface():
|
|
| 426 |
gr.Markdown(
|
| 427 |
"""
|
| 428 |
---
|
| 429 |
-
###
|
| 430 |
|
| 431 |
-
-
|
| 432 |
-
-
|
| 433 |
-
-
|
| 434 |
-
-
|
| 435 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 436 |
|
| 437 |
-
### Speaker ID について
|
| 438 |
-
- **単一スピーカーモデル**: Speaker ID は無視されます
|
| 439 |
-
- **マルチスピーカーモデル**: Speaker ID で話者を切り替え
|
| 440 |
-
"""
|
| 441 |
)
|
| 442 |
|
| 443 |
return demo
|
|
@@ -454,4 +518,4 @@ if __name__ == "__main__":
|
|
| 454 |
server_port=7860,
|
| 455 |
share=False,
|
| 456 |
show_error=True
|
| 457 |
-
)
|
|
|
|
| 319 |
# Get available models
|
| 320 |
available_models = get_available_models()
|
| 321 |
|
| 322 |
+
# Load speaker images
|
| 323 |
+
imgs_dir = os.path.join(SCRIPT_DIR, "imgs")
|
| 324 |
+
speaker_images = []
|
| 325 |
+
if os.path.exists(imgs_dir):
|
| 326 |
+
# Sort by numerical filename (0.webp, 1.webp, ...)
|
| 327 |
+
image_files = sorted(glob.glob(os.path.join(imgs_dir, "*.webp")),
|
| 328 |
+
key=lambda x: int(os.path.splitext(os.path.basename(x))[0]))
|
| 329 |
+
speaker_images = [(img, f"Speaker {os.path.splitext(os.path.basename(img))[0]}") for img in image_files]
|
| 330 |
+
|
| 331 |
with gr.Blocks(
|
| 332 |
+
title="AI Gaming Voice",
|
| 333 |
) as demo:
|
| 334 |
gr.Markdown(
|
| 335 |
"""
|
| 336 |
+
# AI Gaming Voice - 🍵 Matcha-TTS ONNX (Japanese) / 日本語
|
| 337 |
|
| 338 |
+
### 6 Voices - 140MB or 42MB(Qint8 but slow)
|
| 339 |
+
Japanese Text-to-Speech.(Half-width alphanumeric characters are not supported. Please correct/fix it.)
|
| 340 |
+
日本語音声合成です。(半角・英数字は未対応・直してください。)
|
| 341 |
"""
|
| 342 |
)
|
| 343 |
|
|
|
|
| 358 |
placeholder="日本語のテキストを入力してください..."
|
| 359 |
)
|
| 360 |
|
| 361 |
+
# Speaker Selection Gallery
|
| 362 |
+
if speaker_images:
|
| 363 |
+
gr.Markdown("### 話者選択 / Select Speaker")
|
| 364 |
+
speaker_gallery = gr.Gallery(
|
| 365 |
+
value=speaker_images,
|
| 366 |
+
label="話者 / Speakers",
|
| 367 |
+
show_label=False,
|
| 368 |
+
columns=6,
|
| 369 |
+
rows=1,
|
| 370 |
+
height=160,
|
| 371 |
+
allow_preview=False,
|
| 372 |
+
interactive=False,
|
| 373 |
+
object_fit="cover",
|
| 374 |
+
elem_id="speaker_gallery"
|
| 375 |
+
)
|
| 376 |
+
|
| 377 |
# Speaker ID
|
| 378 |
speaker_id = gr.Number(
|
| 379 |
label="Speaker ID (スピーカーID)",
|
|
|
|
| 381 |
minimum=0,
|
| 382 |
maximum=99,
|
| 383 |
precision=0,
|
| 384 |
+
info="上の画像をタップするか、数値を入力してください"
|
| 385 |
)
|
| 386 |
|
| 387 |
with gr.Row():
|
|
|
|
| 430 |
gr.Examples(
|
| 431 |
examples=[
|
| 432 |
["こんにちは、世界!", "g003_ep5709.onnx", 0, 0.667, 1.0],
|
| 433 |
+
["エイアイゲーミングボイス", "g003_ep5709.onnx", 0, 0.667, 0.8],
|
| 434 |
+
["わたくしの名前はストラよ", "g003_ep5709.onnx", 0, 0.667, 1.0],
|
| 435 |
+
["わたしの名前はシムですよ", "g003_ep5709.onnx", 1, 0.667, 1.0],
|
| 436 |
+
["わたしはナラともうします", "g003_ep5709.onnx", 2, 0.667, 1.0],
|
| 437 |
+
["わたし、ロールプリンよ!", "g003_ep5709.onnx", 3, 0.667, 1.0],
|
| 438 |
+
["僕の名前はショーンだよ", "g003_ep5709.onnx", 4, 0.667, 1.0],
|
| 439 |
+
["私の名前はありません", "g003_ep5709.onnx", 5, 0.667, 1.0],
|
| 440 |
],
|
| 441 |
inputs=[text_input, model_dropdown, speaker_id, temperature, speaking_rate],
|
| 442 |
label="例文 / Examples"
|
| 443 |
)
|
| 444 |
|
| 445 |
# Event handlers
|
| 446 |
+
|
| 447 |
+
# Gallery click handler
|
| 448 |
+
if speaker_images:
|
| 449 |
+
def on_gallery_select(evt: gr.SelectData):
|
| 450 |
+
return evt.index
|
| 451 |
+
|
| 452 |
+
speaker_gallery.select(
|
| 453 |
+
fn=on_gallery_select,
|
| 454 |
+
inputs=None,
|
| 455 |
+
outputs=speaker_id
|
| 456 |
+
).then(
|
| 457 |
+
fn=synthesise,
|
| 458 |
+
inputs=[text_input, model_dropdown, speaker_id, temperature, speaking_rate],
|
| 459 |
+
outputs=[audio_output, info_output]
|
| 460 |
+
)
|
| 461 |
+
|
| 462 |
synthesise_btn.click(
|
| 463 |
fn=synthesise,
|
| 464 |
inputs=[text_input, model_dropdown, speaker_id, temperature, speaking_rate],
|
|
|
|
| 473 |
gr.Markdown(
|
| 474 |
"""
|
| 475 |
---
|
| 476 |
+
### ℹ️ Information / 情報
|
| 477 |
|
| 478 |
+
- **Model / モデル**: Matcha-TTS (ONNX)
|
| 479 |
+
- **Inference / 推論**: ONNX Runtime
|
| 480 |
+
- **Phonemizer / 音素化**: `pyopenjtalk`
|
| 481 |
+
- **ZeroGPU**: Optimized for fast startup & inference / 高速起動・推論に最適化
|
| 482 |
+
|
| 483 |
+
### 🗣️ Speaker Selection / 話者選択
|
| 484 |
+
- **Click Image / 画像クリック**: Selects speaker & generates audio / 話者を選択して音声を生成
|
| 485 |
+
- **Speaker ID**: Manual input also supported / 手動入力も可能
|
| 486 |
+
|
| 487 |
+
### FAQ
|
| 488 |
+
**Why AI Gaming Voice?**
|
| 489 |
+
- I have a plan to support another ONNX models.
|
| 490 |
+
|
| 491 |
+
**Model Difference**
|
| 492 |
+
- **qint8**: 1/3 size but slow.
|
| 493 |
+
|
| 494 |
+
**How to create my voice**
|
| 495 |
+
- [Github](https://github.com/akjava/Matcha-TTS-Japanese) - I'll update here.
|
| 496 |
+
|
| 497 |
+
**Model**
|
| 498 |
+
- [Huggingface:matcha-tts_ja_100speakers_group003f-CL-V2](https://huggingface.co/Akjava/matcha-tts_ja_100speakers_group003f-CL-V2)
|
| 499 |
+
|
| 500 |
+
|
| 501 |
+
**Who are they?**
|
| 502 |
+
- [Youtube:4 of them are member of AI Gaming Circle](https://www.youtube.com/@ai-gaming-circle)
|
| 503 |
+
"""
|
| 504 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 505 |
)
|
| 506 |
|
| 507 |
return demo
|
|
|
|
| 518 |
server_port=7860,
|
| 519 |
share=False,
|
| 520 |
show_error=True
|
| 521 |
+
)
|
imgs/0.webp
ADDED
|
imgs/1.webp
ADDED
|
imgs/2.webp
ADDED
|
imgs/3.webp
ADDED
|
imgs/4.webp
ADDED
|
imgs/5.webp
ADDED
|