sachin commited on
Commit
38a081b
·
1 Parent(s): 22afc1d
Files changed (1) hide show
  1. app.py +16 -1
app.py CHANGED
@@ -3,7 +3,22 @@ import requests
3
 
4
  def text_to_speech(text):
5
  # Construct URL with plain text as query parameter
6
- url = (f"https://slabstech-dhwani-server-workshop.hf.space/v1/audio/speech?"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  f"input={text}&response_format=mp3")
8
 
9
  headers = {
 
3
 
4
  def text_to_speech(text):
5
  # Construct URL with plain text as query parameter
6
+
7
+ import os
8
+
9
+ # Get the base URL (IP or domain) from environment variable
10
+ base_url = os.getenv("DWANI_AI_API_BASE_URL")
11
+
12
+ if not base_url:
13
+ raise ValueError("DWANI_AI_API_BASE_URL environment variable is not set")
14
+
15
+ # Define the endpoint path
16
+ endpoint = "/v1/audio/speech?"
17
+
18
+ # Construct the full API URL
19
+ url = f"{base_url.rstrip('/')}{endpoint}"
20
+
21
+ url = (f"{url}"
22
  f"input={text}&response_format=mp3")
23
 
24
  headers = {