MaykaGR commited on
Commit
53d65e5
verified
1 Parent(s): 6fd841c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -6
app.py CHANGED
@@ -28,9 +28,10 @@ with gr.Blocks(theme=gr.themes.Ocean(primary_hue="pink", neutral_hue="indigo", f
28
 
29
  def describir(url):
30
  raw_image = Image.open(requests.get(url, stream=True).raw).convert('RGB')
31
- inputs = processor(raw_image, return_tensors="pt").to("cpu")
32
- out = model.generate(**inputs)
33
- return processor.decode(out[0], skip_special_tokens=True)
 
34
 
35
  def leer(texto):
36
  response = requests.post("https://charly-text-to-speech.hf.space/run/predict", json={
@@ -38,10 +39,20 @@ with gr.Blocks(theme=gr.themes.Ocean(primary_hue="pink", neutral_hue="indigo", f
38
  texto,
39
  ]}).json()
40
 
41
- print(response)
42
- data = response['data']
 
 
 
 
 
43
 
44
- return data
 
 
 
 
 
45
 
46
 
47
  button.click(describir, [textbox], output)
 
28
 
29
  def describir(url):
30
  raw_image = Image.open(requests.get(url, stream=True).raw).convert('RGB')
31
+ #inputs = processor(raw_image, return_tensors="pt").to("cpu")
32
+ #out = model.generate(**inputs)
33
+ #return processor.decode(out[0], skip_special_tokens=True)
34
+ return "description"
35
 
36
  def leer(texto):
37
  response = requests.post("https://charly-text-to-speech.hf.space/run/predict", json={
 
39
  texto,
40
  ]}).json()
41
 
42
+ data = response['data'][0]
43
+
44
+ # Extraer la parte de base64 del string (eliminar el prefijo 'data:audio/flac;base64,')
45
+ audio_base64 = data.split(',')[1]
46
+
47
+ # Decodificar el string base64
48
+ audio_data = base64.b64decode(audio_base64)
49
 
50
+ # Crear un archivo temporal
51
+ with tempfile.NamedTemporaryFile(delete=False, suffix='.flac') as temp_audio_file:
52
+ temp_audio_file.write(audio_data)
53
+ temp_audio_path = temp_audio_file.name
54
+
55
+ return temp_audio_path
56
 
57
 
58
  button.click(describir, [textbox], output)