neha-ai-playground commited on
Commit
48f0586
·
1 Parent(s): 8823598

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -1
app.py CHANGED
@@ -36,6 +36,23 @@ def generate_story(scenario):
36
  st.subheader(story)
37
  return story
38
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
  scenario = img2Text("photo.jpg")
40
  story = generate_story(scenario)
41
-
 
36
  st.subheader(story)
37
  return story
38
 
39
+ #textToSpeech
40
+
41
+ def text2Speech(story) :
42
+ API_URL = "https://api-inference.huggingface.co/models/microsoft/speecht5_tts"
43
+ headers = {"Authorization": "Bearer {HF_TOKEN}"}
44
+
45
+ def query(payload):
46
+ response = requests.post(API_URL, headers=headers, json=payload)
47
+ return response.json()
48
+
49
+ output = query({
50
+ "inputs": story,
51
+ })
52
+ with open('audio.flac','wb') as file:
53
+ file.write(output.content)
54
+
55
+
56
  scenario = img2Text("photo.jpg")
57
  story = generate_story(scenario)
58
+ text2Speech(story)