2121-8 commited on
Commit
a27df4f
·
verified ·
1 Parent(s): f15c4af

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +25 -0
README.md CHANGED
@@ -102,6 +102,31 @@ sf.write("parler_tts_japanese_out.wav", audio_arr, model.config.sampling_rate)
102
 
103
  ### 🎯 特定の話者を指定する方法
104
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
105
 
106
 
107
  ---
 
102
 
103
  ### 🎯 特定の話者を指定する方法
104
 
105
+ ```python
106
+ import torch
107
+ from parler_tts import ParlerTTSForConditionalGeneration
108
+ from transformers import AutoTokenizer
109
+ import soundfile as sf
110
+ from rubyinserter import add_ruby
111
+
112
+ device = "cuda:0" if torch.cuda.is_available() else "cpu"
113
+
114
+ model = ParlerTTSForConditionalGeneration.from_pretrained("2121-8/japanese-parler-tts-mini").to(device)
115
+ prompt_tokenizer = AutoTokenizer.from_pretrained("2121-8/japanese-parler-tts-mini", subfolder="prompt_tokenizer")
116
+ description_tokenizer = AutoTokenizer.from_pretrained("2121-8/japanese-parler-tts-mini", subfolder="description_tokenizer")
117
+
118
+ prompt = "こんにちは、今日はどのようにお過ごしですか?"
119
+ description = "JSUT speaker with a slightly high-pitched voice delivers her words at a moderate speed with a quite monotone tone in a confined environment, resulting in a quite clear audio recording."
120
+
121
+
122
+ prompt = add_ruby(prompt)
123
+ input_ids = description_tokenizer(description, return_tensors="pt").input_ids.to(device)
124
+ prompt_input_ids = prompt_tokenizer(prompt, return_tensors="pt").input_ids.to(device)
125
+
126
+ generation = model.generate(input_ids=input_ids, prompt_input_ids=prompt_input_ids)
127
+ audio_arr = generation.cpu().numpy().squeeze()
128
+ sf.write("parler_tts_japanese_out.wav", audio_arr, model.config.sampling_rate)
129
+ ```
130
 
131
 
132
  ---