ariankhalfani commited on
Commit
e8892bb
·
verified ·
1 Parent(s): ab44c82

Update LLMwithvoice.py

Browse files
Files changed (1) hide show
  1. LLMwithvoice.py +3 -0
LLMwithvoice.py CHANGED
@@ -1,6 +1,7 @@
1
  import requests
2
  from pydub import AudioSegment
3
  from io import BytesIO
 
4
 
5
  # Hugging Face API URLs
6
  API_URL_ROBERTA = "https://api-inference.huggingface.co/models/deepset/roberta-base-squad2"
@@ -43,8 +44,10 @@ def generate_speech(api_token, answer):
43
  return audio_file
44
  except requests.exceptions.HTTPError as e:
45
  print(f"HTTP error occurred: {e}")
 
46
  except Exception as e:
47
  print(f"An unexpected error occurred: {e}")
 
48
 
49
  # Function to interface with Gradio
50
  def gradio_interface(api_token, context, prompt):
 
1
  import requests
2
  from pydub import AudioSegment
3
  from io import BytesIO
4
+ import gradio as gr
5
 
6
  # Hugging Face API URLs
7
  API_URL_ROBERTA = "https://api-inference.huggingface.co/models/deepset/roberta-base-squad2"
 
44
  return audio_file
45
  except requests.exceptions.HTTPError as e:
46
  print(f"HTTP error occurred: {e}")
47
+ return None
48
  except Exception as e:
49
  print(f"An unexpected error occurred: {e}")
50
+ return None
51
 
52
  # Function to interface with Gradio
53
  def gradio_interface(api_token, context, prompt):