kevinwang676 commited on
Commit
990357a
1 Parent(s): d3a1252

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -0
app.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ from modelscope.models.audio.tts import SambertHifigan
3
+ from modelscope.pipelines import pipeline
4
+ from modelscope.utils.constant import Tasks
5
+
6
+ model_dir = os.path.abspath("./pretrain_work_dir")
7
+
8
+ custom_infer_abs = {
9
+ 'voice_name':
10
+ 'F7',
11
+ 'am_ckpt':
12
+ os.path.join(model_dir, 'tmp_am', 'ckpt'),
13
+ 'am_config':
14
+ os.path.join(model_dir, 'tmp_am', 'config.yaml'),
15
+ 'voc_ckpt':
16
+ os.path.join(model_dir, 'orig_model', 'basemodel_16k', 'hifigan', 'ckpt'),
17
+ 'voc_config':
18
+ os.path.join(model_dir, 'orig_model', 'basemodel_16k', 'hifigan',
19
+ 'config.yaml'),
20
+ 'audio_config':
21
+ os.path.join(model_dir, 'data', 'audio_config.yaml'),
22
+ 'se_file':
23
+ os.path.join(model_dir, 'data', 'se', 'se.npy')
24
+ }
25
+ kwargs = {'custom_ckpt': custom_infer_abs}
26
+
27
+ model_id = SambertHifigan(os.path.join(model_dir, "orig_model"), **kwargs)
28
+
29
+ inference = pipeline(task=Tasks.text_to_speech, model=model_id)
30
+ output = inference(input="今天的天气真不错")
31
+
32
+ import IPython.display as ipd
33
+ ipd.Audio(output["output_wav"], rate=16000)