litagin commited on
Commit
0554880
ยท
1 Parent(s): 4af6bb4
Files changed (3) hide show
  1. README.md +1 -1
  2. app.py +19 -2
  3. requirements.txt +2 -1
README.md CHANGED
@@ -1,5 +1,5 @@
1
  ---
2
- title: Parler Tts Japanese
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
- print(f"Prompt: {prompt}, Description: {description}")
 
18
  if len(prompt) > 150:
19
  return "Text is too long. Please keep it under 150 characters.", None
 
 
20
  prompt = add_ruby(prompt)
21
- print(f"Prompt with ruby: {prompt}")
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