txya900619 commited on
Commit
5006a88
·
1 Parent(s): c3b935f

feat: add TTS patch for custom char

Browse files
Files changed (2) hide show
  1. app.py +7 -1
  2. replace/tts.py +70 -0
app.py CHANGED
@@ -1,10 +1,14 @@
1
  import gradio as gr
2
  import numpy as np
3
  import spaces
 
4
 
5
  from ipa import g2p
6
  from ipa.ipa import text_to_ipa
7
  from models import models_config
 
 
 
8
 
9
 
10
  @spaces.GPU
@@ -201,9 +205,11 @@ def update_example(language):
201
  ],
202
  )
203
 
 
204
  def get_title():
205
  with open("DEMO.md") as tong:
206
- return tong.readline().strip('# ')
 
207
 
208
  demo = gr.Blocks(
209
  title=get_title(),
 
1
  import gradio as gr
2
  import numpy as np
3
  import spaces
4
+ import TTS
5
 
6
  from ipa import g2p
7
  from ipa.ipa import text_to_ipa
8
  from models import models_config
9
+ from replace.tts import ChangedVitsConfig
10
+
11
+ TTS.tts.configs.vits_config.VitsConfig = ChangedVitsConfig
12
 
13
 
14
  @spaces.GPU
 
205
  ],
206
  )
207
 
208
+
209
  def get_title():
210
  with open("DEMO.md") as tong:
211
+ return tong.readline().strip("# ")
212
+
213
 
214
  demo = gr.Blocks(
215
  title=get_title(),
replace/tts.py ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from dataclasses import dataclass
2
+ from typing import Dict, List
3
+
4
+ from coqpit import Coqpit
5
+ from TTS.tts.configs.vits_config import VitsConfig
6
+
7
+
8
+ @dataclass
9
+ class CharactersConfig(Coqpit):
10
+ """Defines arguments for the `BaseCharacters` or `BaseVocabulary` and their subclasses.
11
+
12
+ Args:
13
+ characters_class (str):
14
+ Defines the class of the characters used. If None, we pick ```Phonemes``` or ```Graphemes``` based on
15
+ the configuration. Defaults to None.
16
+
17
+ vocab_dict (dict):
18
+ Defines the vocabulary dictionary used to encode the characters. Defaults to None.
19
+
20
+ pad (str):
21
+ characters in place of empty padding. Defaults to None.
22
+
23
+ eos (str):
24
+ characters showing the end of a sentence. Defaults to None.
25
+
26
+ bos (str):
27
+ characters showing the beginning of a sentence. Defaults to None.
28
+
29
+ blank (str):
30
+ Optional character used between characters by some models for better prosody. Defaults to `_blank`.
31
+
32
+ characters (str):
33
+ character set used by the model. Characters not in this list are ignored when converting input text to
34
+ a list of sequence IDs. Defaults to None.
35
+
36
+ punctuations (str):
37
+ characters considered as punctuation as parsing the input sentence. Defaults to None.
38
+
39
+ phonemes (str):
40
+ characters considered as parsing phonemes. This is only for backwards compat. Use `characters` for new
41
+ models. Defaults to None.
42
+
43
+ is_unique (bool):
44
+ remove any duplicate characters in the character lists. It is a bandaid for compatibility with the old
45
+ models trained with character lists with duplicates. Defaults to True.
46
+
47
+ is_sorted (bool):
48
+ Sort the characters in alphabetical order. Defaults to True.
49
+ """
50
+
51
+ characters_class: str = None
52
+
53
+ # using BaseVocabulary
54
+ vocab_dict: Dict = None
55
+
56
+ # using on BaseCharacters
57
+ pad: str = None
58
+ eos: str = None
59
+ bos: str = None
60
+ blank: str = None
61
+ characters: List[str] = None
62
+ punctuations: str = None
63
+ phonemes: str = None
64
+ is_unique: bool = True # for backwards compatibility of models trained with char sets with duplicates
65
+ is_sorted: bool = True
66
+
67
+
68
+ @dataclass
69
+ class ChangedVitsConfig(VitsConfig):
70
+ characters: CharactersConfig = None