Peca33 commited on
Commit
81a55fb
verified
1 Parent(s): 89c5d72

sugerencia perplexity

Browse files
Files changed (1) hide show
  1. app.py +3 -11
app.py CHANGED
@@ -7,19 +7,14 @@ from bark import generate_audio
7
  from scipy.io.wavfile import write
8
  import tempfile
9
 
10
-
11
- # Cargar el modelo Whisper-small y bark
12
  transcribir = pipeline("automatic-speech-recognition", model="openai/whisper-small")
13
- """bark = pipeline("text-to-speech", model="suno/bark")"""
14
-
15
 
16
  # Funci贸n para transcribir el audio y traducir el audio de entrada
17
  def transcribir_audio(audio):
18
- # Usamos el pipeline de Hugging Face para la transcripci贸n
19
- result = transcribir_audio(audio_file, task="translate")
20
  return result["text"]
21
 
22
-
23
  # Funci贸n para generar el audio
24
  def generar_audio(text):
25
  if not isinstance(text, str):
@@ -29,7 +24,6 @@ def generar_audio(text):
29
  temp_wav = tempfile.NamedTemporaryFile(delete=False, suffix=".wav")
30
  write(temp_wav.name, 24000, (audio_array * 32767).astype(np.int16))
31
  return temp_wav.name
32
-
33
 
34
  def process_audio(audio_file):
35
  try:
@@ -43,8 +37,6 @@ def process_audio(audio_file):
43
  except Exception as e:
44
  return str(e), None
45
 
46
-
47
-
48
  # Crear interfaz Gradio
49
  with gr.Blocks() as demo:
50
  gr.Markdown("### Transcripci贸n y S铆ntesis de Voz")
@@ -58,4 +50,4 @@ with gr.Blocks() as demo:
58
  process_button.click(process_audio, inputs=input_audio, outputs=[transcription_output, output_audio])
59
 
60
  # Lanzar la app
61
- demo.launch(share=True)
 
7
  from scipy.io.wavfile import write
8
  import tempfile
9
 
10
+ # Cargar el modelo Whisper-small
 
11
  transcribir = pipeline("automatic-speech-recognition", model="openai/whisper-small")
 
 
12
 
13
  # Funci贸n para transcribir el audio y traducir el audio de entrada
14
  def transcribir_audio(audio):
15
+ result = transcribir(audio, task="translate")
 
16
  return result["text"]
17
 
 
18
  # Funci贸n para generar el audio
19
  def generar_audio(text):
20
  if not isinstance(text, str):
 
24
  temp_wav = tempfile.NamedTemporaryFile(delete=False, suffix=".wav")
25
  write(temp_wav.name, 24000, (audio_array * 32767).astype(np.int16))
26
  return temp_wav.name
 
27
 
28
  def process_audio(audio_file):
29
  try:
 
37
  except Exception as e:
38
  return str(e), None
39
 
 
 
40
  # Crear interfaz Gradio
41
  with gr.Blocks() as demo:
42
  gr.Markdown("### Transcripci贸n y S铆ntesis de Voz")
 
50
  process_button.click(process_audio, inputs=input_audio, outputs=[transcription_output, output_audio])
51
 
52
  # Lanzar la app
53
+ demo.launch(share=True)