Jofthomas HF staff commited on
Commit
31fc42e
1 Parent(s): 19a01a7

Update TextGen/router.py

Browse files
Files changed (1) hide show
  1. TextGen/router.py +13 -6
TextGen/router.py CHANGED
@@ -20,8 +20,11 @@ from gradio_client import Client
20
  class Message(BaseModel):
21
  npc: str | None = None
22
  input: str | None = None
23
-
24
-
 
 
 
25
  song_base_api=os.environ["VERCEL_API"]
26
 
27
  my_hf_token=os.environ["HF_TOKEN"]
@@ -73,14 +76,18 @@ def api_home():
73
  def inference(message: Message):
74
  return generate_text(prompt=message.input)
75
 
76
-
 
 
 
77
  @app.get("/generate_wav")
78
- async def generate_wav(text: str, language: str = "en",voice:str="./voices/blacksmith.mp3"):
79
  try:
 
80
  # Use the Gradio client to generate the wav file
81
  result = tts_client.predict(
82
- text, # str in 'Text Prompt' Textbox component
83
- language, # str in 'Language' Dropdown component
84
  voice, # str (filepath on your computer (or URL) of file) in 'Reference Audio' Audio component
85
  voice, # str (filepath on your computer (or URL) of file) in 'Use Microphone for Reference' Audio component
86
  False, # bool in 'Use Microphone' Checkbox component
 
20
  class Message(BaseModel):
21
  npc: str | None = None
22
  input: str | None = None
23
+
24
+ class VoiceMessage(BaseModel):
25
+ npc: str | None = None
26
+ input: str | None = None
27
+ language: str | None = "en"
28
  song_base_api=os.environ["VERCEL_API"]
29
 
30
  my_hf_token=os.environ["HF_TOKEN"]
 
76
  def inference(message: Message):
77
  return generate_text(prompt=message.input)
78
 
79
+ #Dummy function for now
80
+ def determine_vocie_from_npc(npc):
81
+ return "./voices/blacksmith.mp3"
82
+
83
  @app.get("/generate_wav")
84
+ async def generate_wav(message:VoiceMessage):
85
  try:
86
+ voice=determine_vocie_from_npc(message.npc)
87
  # Use the Gradio client to generate the wav file
88
  result = tts_client.predict(
89
+ message.input, # str in 'Text Prompt' Textbox component
90
+ message.language, # str in 'Language' Dropdown component
91
  voice, # str (filepath on your computer (or URL) of file) in 'Reference Audio' Audio component
92
  voice, # str (filepath on your computer (or URL) of file) in 'Use Microphone for Reference' Audio component
93
  False, # bool in 'Use Microphone' Checkbox component