adil9858 commited on
Commit
d8822d7
ยท
verified ยท
1 Parent(s): 93b00c7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -9
app.py CHANGED
@@ -4,12 +4,9 @@ import base64
4
  from PIL import Image
5
  from io import BytesIO
6
  import os
7
- import pyttsx3
8
 
9
- engine = pyttsx3.init()
10
- def speak_text(text):
11
- engine.say(text)
12
- engine.runAndWait()
13
 
14
  # Set the API key
15
  os.environ["TOGETHER_API_KEY"] = "tgp_v1_ci8Tlva09oBrdDV89ULFNcyPgnR9NwNTQyvQ_4XBw3M"
@@ -96,6 +93,28 @@ st.markdown(
96
  unsafe_allow_html=True,
97
  )
98
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99
  # Streamlit app layout
100
  st.title("๐Ÿ”ฎ Visox | Koshur AI")
101
  st.markdown("### See the world through AI's eyes!")
@@ -123,7 +142,8 @@ if img_file_buffer is not None:
123
  st.success('โœ… Analysis complete!')
124
  st.markdown("### AI Description:")
125
  st.write(description)
126
- # Speak the description aloud
127
- if st.button("๐Ÿ”Š Read Aloud"):
128
- speak_text(description)
129
- st.success("Speech complete!")
 
 
4
  from PIL import Image
5
  from io import BytesIO
6
  import os
 
7
 
8
+
9
+
 
 
10
 
11
  # Set the API key
12
  os.environ["TOGETHER_API_KEY"] = "tgp_v1_ci8Tlva09oBrdDV89ULFNcyPgnR9NwNTQyvQ_4XBw3M"
 
93
  unsafe_allow_html=True,
94
  )
95
 
96
+ def tts(text):
97
+ key = 'sk_8db078175c4eba3e2d4b500ffb167c46326e520bdf001f0e'
98
+
99
+
100
+ from elevenlabs.client import ElevenLabs
101
+ from elevenlabs import play
102
+
103
+
104
+
105
+ client = ElevenLabs(api_key=key)
106
+
107
+
108
+ audio = client.text_to_speech.convert(
109
+ text=text,
110
+ voice_id="JBFqnCBsd6RMkjVDRZzb",
111
+ model_id="eleven_multilingual_v2",
112
+ output_format="mp3_44100_128",
113
+ )
114
+
115
+
116
+ play(audio)
117
+
118
  # Streamlit app layout
119
  st.title("๐Ÿ”ฎ Visox | Koshur AI")
120
  st.markdown("### See the world through AI's eyes!")
 
142
  st.success('โœ… Analysis complete!')
143
  st.markdown("### AI Description:")
144
  st.write(description)
145
+
146
+ tts(descripion)
147
+
148
+
149
+