Spaces:
Running
on
Zero
Running
on
Zero
update
Browse files- README.md +1 -1
- app.py +19 -2
- requirements.txt +2 -1
README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
---
|
2 |
-
title: Parler
|
3 |
emoji: ๐
|
4 |
colorFrom: gray
|
5 |
colorTo: purple
|
|
|
1 |
---
|
2 |
+
title: Japanese Parler-TTS Mini Demo
|
3 |
emoji: ๐
|
4 |
colorFrom: gray
|
5 |
colorTo: purple
|
app.py
CHANGED
@@ -1,24 +1,32 @@
|
|
1 |
import gradio as gr
|
2 |
import spaces
|
3 |
import torch
|
|
|
4 |
from parler_tts import ParlerTTSForConditionalGeneration
|
5 |
from rubyinserter import add_ruby
|
6 |
from transformers import AutoTokenizer
|
7 |
|
8 |
device = "cuda:0" if torch.cuda.is_available() else "cpu"
|
9 |
repo_id = "2121-8/japanese-parler-tts-mini-bate"
|
|
|
|
|
|
|
10 |
model = ParlerTTSForConditionalGeneration.from_pretrained(repo_id).to(device)
|
|
|
11 |
model.eval()
|
12 |
tokenizer = AutoTokenizer.from_pretrained(repo_id)
|
13 |
|
14 |
|
15 |
@spaces.GPU
|
16 |
def parler_tts(prompt: str, description: str):
|
17 |
-
|
|
|
18 |
if len(prompt) > 150:
|
19 |
return "Text is too long. Please keep it under 150 characters.", None
|
|
|
|
|
20 |
prompt = add_ruby(prompt)
|
21 |
-
|
22 |
input_ids = tokenizer(description, return_tensors="pt").input_ids.to(device)
|
23 |
prompt_input_ids = tokenizer(prompt, return_tensors="pt").input_ids.to(device)
|
24 |
with torch.no_grad():
|
@@ -29,6 +37,15 @@ def parler_tts(prompt: str, description: str):
|
|
29 |
return "Success", (model.config.sampling_rate, audio_arr)
|
30 |
|
31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
with gr.Blocks() as app:
|
33 |
prompt = gr.Textbox(label="ๅ
ฅๅๆ็ซ ")
|
34 |
description = gr.Textbox(
|
|
|
1 |
import gradio as gr
|
2 |
import spaces
|
3 |
import torch
|
4 |
+
from loguru import logger
|
5 |
from parler_tts import ParlerTTSForConditionalGeneration
|
6 |
from rubyinserter import add_ruby
|
7 |
from transformers import AutoTokenizer
|
8 |
|
9 |
device = "cuda:0" if torch.cuda.is_available() else "cpu"
|
10 |
repo_id = "2121-8/japanese-parler-tts-mini-bate"
|
11 |
+
|
12 |
+
logger.info(f"Using device: {device}")
|
13 |
+
logger.info(f"Loading model from: {repo_id}")
|
14 |
model = ParlerTTSForConditionalGeneration.from_pretrained(repo_id).to(device)
|
15 |
+
logger.success("Model loaded successfully")
|
16 |
model.eval()
|
17 |
tokenizer = AutoTokenizer.from_pretrained(repo_id)
|
18 |
|
19 |
|
20 |
@spaces.GPU
|
21 |
def parler_tts(prompt: str, description: str):
|
22 |
+
logger.info(f"Prompt: {prompt}")
|
23 |
+
logger.info(f"Description: {description}")
|
24 |
if len(prompt) > 150:
|
25 |
return "Text is too long. Please keep it under 150 characters.", None
|
26 |
+
if len(description) > 300:
|
27 |
+
return "Description is too long. Please keep it under 300 characters.", None
|
28 |
prompt = add_ruby(prompt)
|
29 |
+
logger.info(f"Prompt with ruby: {prompt}")
|
30 |
input_ids = tokenizer(description, return_tensors="pt").input_ids.to(device)
|
31 |
prompt_input_ids = tokenizer(prompt, return_tensors="pt").input_ids.to(device)
|
32 |
with torch.no_grad():
|
|
|
37 |
return "Success", (model.config.sampling_rate, audio_arr)
|
38 |
|
39 |
|
40 |
+
md = """
|
41 |
+
# Japanese Parler-TTS Mini (ฮฒ็) ใใข
|
42 |
+
|
43 |
+
็ฌฌไธ่
ใซใใ [Japanese Parler-TTS Mini (ฮฒ็)](https://huggingface.co/2121-8/japanese-parler-tts-mini-bate) ใฎ้ณๅฃฐๅๆใใขใงใใ
|
44 |
+
|
45 |
+
- ๅ
ฅๅๆ็ซ : 150ๆๅญไปฅๅ
ใฎๆ็ซ ใๅ
ฅๅใใฆใใ ใใใ
|
46 |
+
- ่ชฌๆๆ็ซ : 300ๆๅญไปฅๅ
ใฎๆ็ซ ใๅ
ฅๅใใฆใใ ใใใ้ณๅฃฐใฎ็นๅพดใ่ชฌๆใใๆ็ซ ใๅ
ฅๅใใพใ๏ผๅคๅ๏ผใ
|
47 |
+
"""
|
48 |
+
|
49 |
with gr.Blocks() as app:
|
50 |
prompt = gr.Textbox(label="ๅ
ฅๅๆ็ซ ")
|
51 |
description = gr.Textbox(
|
requirements.txt
CHANGED
@@ -1,2 +1,3 @@
|
|
1 |
git+https://github.com/huggingface/parler-tts.git
|
2 |
-
git+https://github.com/getuka/RubyInserter.git
|
|
|
|
1 |
git+https://github.com/huggingface/parler-tts.git
|
2 |
+
git+https://github.com/getuka/RubyInserter.git
|
3 |
+
loguru
|