Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -10,6 +10,7 @@ import asyncio
|
|
10 |
import aiofiles
|
11 |
import pypdf
|
12 |
import os
|
|
|
13 |
from typing import List, Dict, Tuple
|
14 |
|
15 |
class PodcastGenerator:
|
@@ -283,9 +284,17 @@ Follow this example structure:
|
|
283 |
|
284 |
async def generate_podcast(self, input_text: str, language: str, speaker1: str, speaker2: str, api_key: str) -> str:
|
285 |
gr.Info("Generating podcast script...")
|
|
|
286 |
podcast_json = await self.generate_script(input_text, language, api_key)
|
|
|
|
|
|
|
287 |
gr.Info("Generating podcast audio files...")
|
|
|
288 |
audio_files = await asyncio.gather(*[self.tts_generate(item['line'], item['speaker'], speaker1, speaker2) for item in podcast_json['podcast']])
|
|
|
|
|
|
|
289 |
combined_audio = await self.combine_audio_files(audio_files)
|
290 |
return combined_audio
|
291 |
|
@@ -314,6 +323,9 @@ class TextExtractor:
|
|
314 |
raise ValueError(f"Unsupported file type: {file_extension}")
|
315 |
|
316 |
async def process_input(input_text: str, input_file, language: str, speaker1: str, speaker2: str, api_key: str = "") -> str:
|
|
|
|
|
|
|
317 |
voice_names = {
|
318 |
"Andrew - English (United States)": "en-US-AndrewMultilingualNeural",
|
319 |
"Ava - English (United States)": "en-US-AvaMultilingualNeural",
|
@@ -335,7 +347,12 @@ async def process_input(input_text: str, input_file, language: str, speaker1: st
|
|
335 |
api_key = os.getenv("GENAI_API_KEY")
|
336 |
|
337 |
podcast_generator = PodcastGenerator()
|
338 |
-
|
|
|
|
|
|
|
|
|
|
|
339 |
|
340 |
# Define Gradio interface
|
341 |
iface = gr.Interface(
|
|
|
10 |
import aiofiles
|
11 |
import pypdf
|
12 |
import os
|
13 |
+
import time
|
14 |
from typing import List, Dict, Tuple
|
15 |
|
16 |
class PodcastGenerator:
|
|
|
284 |
|
285 |
async def generate_podcast(self, input_text: str, language: str, speaker1: str, speaker2: str, api_key: str) -> str:
|
286 |
gr.Info("Generating podcast script...")
|
287 |
+
start_time = time.time()
|
288 |
podcast_json = await self.generate_script(input_text, language, api_key)
|
289 |
+
end_time = time.time()
|
290 |
+
gr.Info(f"Successfully generated podcast script in {(end_time - start_time):.2f} seconds!")
|
291 |
+
|
292 |
gr.Info("Generating podcast audio files...")
|
293 |
+
start_time = time.time()
|
294 |
audio_files = await asyncio.gather(*[self.tts_generate(item['line'], item['speaker'], speaker1, speaker2) for item in podcast_json['podcast']])
|
295 |
+
end_time = time.time()
|
296 |
+
gr.Info(f"Successfully generated podcast audio files in {(end_time - start_time):.2f} seconds!")
|
297 |
+
|
298 |
combined_audio = await self.combine_audio_files(audio_files)
|
299 |
return combined_audio
|
300 |
|
|
|
323 |
raise ValueError(f"Unsupported file type: {file_extension}")
|
324 |
|
325 |
async def process_input(input_text: str, input_file, language: str, speaker1: str, speaker2: str, api_key: str = "") -> str:
|
326 |
+
gr.Info("Starting podcast generation...")
|
327 |
+
start_time = time.time()
|
328 |
+
|
329 |
voice_names = {
|
330 |
"Andrew - English (United States)": "en-US-AndrewMultilingualNeural",
|
331 |
"Ava - English (United States)": "en-US-AvaMultilingualNeural",
|
|
|
347 |
api_key = os.getenv("GENAI_API_KEY")
|
348 |
|
349 |
podcast_generator = PodcastGenerator()
|
350 |
+
podcast = await podcast_generator.generate_podcast(input_text, language, speaker1, speaker2, api_key)
|
351 |
+
|
352 |
+
end_time = time.time()
|
353 |
+
gr.Info(f"Successfully generated podcast in {(end_time - start_time):.2f} seconds!")
|
354 |
+
|
355 |
+
return podcast
|
356 |
|
357 |
# Define Gradio interface
|
358 |
iface = gr.Interface(
|