gnosticdev commited on
Commit
e6fe746
·
verified ·
1 Parent(s): 996224c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -28
app.py CHANGED
@@ -17,49 +17,33 @@ async def synthesize(article_url, text_input, language):
17
  config = ConversationConfig()
18
  converter = URLToAudioConverter(config, llm_api_key=os.environ.get("TOGETHER_API_KEY"))
19
 
20
- # Definir voces según idioma (puedes añadir más)
21
  voices = {
22
- "en": ("en-US-AvaMultilingualNeural", "en-US-AndrewMultilingualNeural"), # Voces originales humanizadas
23
- "es": ("es-ES-AlvaroNeural", "es-ES-ElviraNeural") # Voces en español
24
  }
25
- voice1, voice2 = voices.get(language, voices["en"]) # Default: inglés
26
-
27
- # Procesar texto manual
28
  if text_input:
29
- output_file, conversation = await converter.text_to_audio(
30
- text_input,
31
- voice1,
32
- voice2
33
- )
34
- return conversation, output_file
35
-
36
- # Procesar URL
37
  else:
38
- output_file, conversation = await converter.url_to_audio(
39
- article_url,
40
- voice1,
41
- voice2
42
- )
43
- return conversation, output_file
44
 
 
45
  except Exception as e:
46
  return f"Error: {str(e)}", None
47
 
48
  with gr.Blocks(theme='gstaff/sketch') as demo:
49
- gr.Markdown("# 🎙 Podcast Converter (Human-like Voices)")
50
  with gr.Group():
51
  text_url = gr.Textbox(label="Article URL (optional)", placeholder="https://...")
52
- text_input = gr.Textbox(label="Or paste text directly", lines=5, placeholder="Type your content here...")
53
- language = gr.Dropdown(
54
- label="Language",
55
- choices=["en", "es"], # Añade más si necesitas
56
- value="en"
57
- )
58
  btn = gr.Button("Generate Podcast", variant="primary")
59
 
60
  with gr.Row():
61
  conv_display = gr.Textbox(label="Conversation", interactive=False, lines=10)
62
- aud = gr.Audio(label="Generated Podcast", interactive=False)
63
 
64
  btn.click(
65
  synthesize_sync,
 
17
  config = ConversationConfig()
18
  converter = URLToAudioConverter(config, llm_api_key=os.environ.get("TOGETHER_API_KEY"))
19
 
20
+ # Voces humanizadas (inglés) o español
21
  voices = {
22
+ "en": ("en-US-AvaMultilingualNeural", "en-US-AndrewMultilingualNeural"),
23
+ "es": ("es-ES-AlvaroNeural", "es-ES-ElviraNeural")
24
  }
25
+ voice1, voice2 = voices.get(language, voices["en"])
26
+
 
27
  if text_input:
28
+ output_file, conversation = await converter.text_to_audio(text_input, voice1, voice2)
 
 
 
 
 
 
 
29
  else:
30
+ output_file, conversation = await converter.url_to_audio(article_url, voice1, voice2)
 
 
 
 
 
31
 
32
+ return conversation, output_file
33
  except Exception as e:
34
  return f"Error: {str(e)}", None
35
 
36
  with gr.Blocks(theme='gstaff/sketch') as demo:
37
+ gr.Markdown("# 🎙 Podcast Converter (Human Voices)")
38
  with gr.Group():
39
  text_url = gr.Textbox(label="Article URL (optional)", placeholder="https://...")
40
+ text_input = gr.Textbox(label="Or paste text directly", lines=5, placeholder="Type here...")
41
+ language = gr.Dropdown(["en", "es"], label="Language", value="en")
 
 
 
 
42
  btn = gr.Button("Generate Podcast", variant="primary")
43
 
44
  with gr.Row():
45
  conv_display = gr.Textbox(label="Conversation", interactive=False, lines=10)
46
+ aud = gr.Audio(label="Podcast", interactive=False)
47
 
48
  btn.click(
49
  synthesize_sync,