gabrielchua commited on
Commit
7c1ccb2
1 Parent(s): d5e153f

fix meloTTS

Browse files
Files changed (1) hide show
  1. app.py +32 -26
app.py CHANGED
@@ -45,6 +45,34 @@ class MediumDialogue(BaseModel):
45
  dialogue: List[DialogueItem] = Field(..., description="A list of dialogue items, typically between 8 to 13 items")
46
 
47
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
  def generate_podcast(
49
  files: List[str],
50
  url: Optional[str],
@@ -56,30 +84,6 @@ def generate_podcast(
56
  ) -> Tuple[str, str]:
57
  """Generate the audio and transcript from the PDFs and/or URL."""
58
 
59
- LANGUAGE_MAPPING = {
60
- "English": "en",
61
- "Chinese": "zh",
62
- "French": "fr",
63
- "German": "de",
64
- "Hindi": "hi",
65
- "Italian": "it",
66
- "Japanese": "ja",
67
- "Korean": "ko",
68
- "Polish": "pl",
69
- "Portuguese": "pt",
70
- "Russian": "ru",
71
- "Spanish": "es",
72
- "Turkish": "tr"
73
- }
74
-
75
- MELO_TTS_LANGUAGE_MAPPING = {
76
- "English": "EN",
77
- "Spanish": "ES",
78
- "French": "FR",
79
- "Chinese": "ZJ",
80
- "Japanese": "JP",
81
- "Korean": "KR",
82
- }
83
 
84
 
85
  text = ""
@@ -160,12 +164,14 @@ def generate_podcast(
160
  transcript += speaker + "\n\n"
161
  total_characters += len(line.text)
162
 
 
 
163
  if not use_advanced_audio:
164
- LANGUAGE_MAPPING = MELO_TTS_LANGUAGE_MAPPING
165
 
166
  # Get audio file path
167
  audio_file_path = generate_podcast_audio(
168
- line.text, line.speaker, LANGUAGE_MAPPING[language], use_advanced_audio
169
  )
170
  # Read the audio file into an AudioSegment
171
  audio_segment = AudioSegment.from_file(audio_file_path)
 
45
  dialogue: List[DialogueItem] = Field(..., description="A list of dialogue items, typically between 8 to 13 items")
46
 
47
 
48
+ LANGUAGE_MAPPING = {
49
+ "English": "en",
50
+ "Chinese": "zh",
51
+ "French": "fr",
52
+ "German": "de",
53
+ "Hindi": "hi",
54
+ "Italian": "it",
55
+ "Japanese": "ja",
56
+ "Korean": "ko",
57
+ "Polish": "pl",
58
+ "Portuguese": "pt",
59
+ "Russian": "ru",
60
+ "Spanish": "es",
61
+ "Turkish": "tr"
62
+ }
63
+
64
+ MELO_TTS_LANGUAGE_MAPPING = {
65
+ "en": "EN",
66
+ "es": "ES",
67
+ "fr": "FR",
68
+ "zh": "ZJ",
69
+ "ja": "JP",
70
+ "ko": "KR",
71
+ }
72
+
73
+
74
+
75
+
76
  def generate_podcast(
77
  files: List[str],
78
  url: Optional[str],
 
84
  ) -> Tuple[str, str]:
85
  """Generate the audio and transcript from the PDFs and/or URL."""
86
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
 
88
 
89
  text = ""
 
164
  transcript += speaker + "\n\n"
165
  total_characters += len(line.text)
166
 
167
+ language_for_tts = language
168
+
169
  if not use_advanced_audio:
170
+ language_for_tts = MELO_TTS_LANGUAGE_MAPPING[language_for_tts]
171
 
172
  # Get audio file path
173
  audio_file_path = generate_podcast_audio(
174
+ line.text, line.speaker, language_for_tts, use_advanced_audio
175
  )
176
  # Read the audio file into an AudioSegment
177
  audio_segment = AudioSegment.from_file(audio_file_path)