zachzzc commited on
Commit
d842d24
·
verified ·
1 Parent(s): c0add26

Update the sound effect normalization

Browse files
Files changed (1) hide show
  1. app.py +17 -1
app.py CHANGED
@@ -89,7 +89,7 @@ PREDEFINED_EXAMPLES = {
89
  },
90
  "single-speaker-bgm": {
91
  "system_prompt": DEFAULT_SYSTEM_PROMPT,
92
- "input_text": "<SE_s>[Music]</SE_s> I will remember this, thought Ender, when I am defeated. To keep dignity, and give honor where it's due, so that defeat is not disgrace. And I hope I don't have to do it often. <SE_e>[Music]</SE_e>",
93
  "description": "Single speaker with BGM using music tag. This is an experimental feature and you may need to try multiple times to get the best result.",
94
  },
95
  }
@@ -184,6 +184,22 @@ def normalize_text(transcript: str):
184
  transcript = transcript.replace(")", " ")
185
  transcript = transcript.replace("°F", " degrees Fahrenheit")
186
  transcript = transcript.replace("°C", " degrees Celsius")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
187
  lines = transcript.split("\n")
188
  transcript = "\n".join([" ".join(line.split()) for line in lines if line.strip()])
189
  transcript = transcript.strip()
 
89
  },
90
  "single-speaker-bgm": {
91
  "system_prompt": DEFAULT_SYSTEM_PROMPT,
92
+ "input_text": "[music start] I will remember this, thought Ender, when I am defeated. To keep dignity, and give honor where it's due, so that defeat is not disgrace. And I hope I don't have to do it often. [music end]",
93
  "description": "Single speaker with BGM using music tag. This is an experimental feature and you may need to try multiple times to get the best result.",
94
  },
95
  }
 
184
  transcript = transcript.replace(")", " ")
185
  transcript = transcript.replace("°F", " degrees Fahrenheit")
186
  transcript = transcript.replace("°C", " degrees Celsius")
187
+
188
+ for tag, replacement in [
189
+ ("[laugh]", "<SE>[Laughter]</SE>"),
190
+ ("[humming start]", "<SE>[Humming]</SE>"),
191
+ ("[humming end]", "<SE_e>[Humming]</SE_e>"),
192
+ ("[music start]", "<SE_s>[Music]</SE_s>"),
193
+ ("[music end]", "<SE_e>[Music]</SE_e>"),
194
+ ("[music]", "<SE>[Music]</SE>"),
195
+ ("[sing start]", "<SE_s>[Singing]</SE_s>"),
196
+ ("[sing end]", "<SE_e>[Singing]</SE_e>"),
197
+ ("[applause]", "<SE>[Applause]</SE>"),
198
+ ("[cheering]", "<SE>[Cheering]</SE>"),
199
+ ("[cough]", "<SE>[Cough]</SE>"),
200
+ ]:
201
+ transcript = transcript.replace(tag, replacement)
202
+
203
  lines = transcript.split("\n")
204
  transcript = "\n".join([" ".join(line.split()) for line in lines if line.strip()])
205
  transcript = transcript.strip()