MaykaGR commited on
Commit
1037518
verified
1 Parent(s): bb1b416

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -12
app.py CHANGED
@@ -6,6 +6,8 @@ from transformers import BlipProcessor, BlipForConditionalGeneration
6
  from fairseq.checkpoint_utils import load_model_ensemble_and_task_from_hf_hub
7
  from fairseq.models.text_to_speech.hub_interface import TTSHubInterface
8
  import IPython.display as ipd
 
 
9
 
10
 
11
  processor = BlipProcessor.from_pretrained("Salesforce/blip-image-captioning-large")
@@ -34,20 +36,14 @@ with gr.Blocks(theme=gr.themes.Ocean(primary_hue="pink", neutral_hue="indigo", f
34
  return processor.decode(out[0], skip_special_tokens=True)
35
 
36
  def leer(texto):
37
- models, cfg, task = load_model_ensemble_and_task_from_hf_hub(
38
- "facebook/fastspeech2-en-ljspeech",
39
- arg_overrides={"vocoder": "hifigan", "fp16": False}
40
- )
41
- modelA = models[0]
42
- TTSHubInterface.update_cfg_with_data_cfg(cfg, task.data_cfg)
43
- generator = task.build_generator(modelA, cfg)
44
-
45
- text = texto
46
 
47
- sample = TTSHubInterface.get_model_input(task, text)
48
- wav, rate = TTSHubInterface.get_prediction(task, modelA, generator, sample)
49
 
50
- return ipd.Audio(wav, rate=rate)
51
 
52
 
53
  button.click(describir, [textbox], output)
 
6
  from fairseq.checkpoint_utils import load_model_ensemble_and_task_from_hf_hub
7
  from fairseq.models.text_to_speech.hub_interface import TTSHubInterface
8
  import IPython.display as ipd
9
+ import requests
10
+
11
 
12
 
13
  processor = BlipProcessor.from_pretrained("Salesforce/blip-image-captioning-large")
 
36
  return processor.decode(out[0], skip_special_tokens=True)
37
 
38
  def leer(texto):
39
+ response = requests.post("https://charly-text-to-speech.hf.space/run/predict", json={
40
+ "data": [
41
+ texto,
42
+ ]}).json()
 
 
 
 
 
43
 
44
+ data = response["data"]
 
45
 
46
+ return data
47
 
48
 
49
  button.click(describir, [textbox], output)