geethareddy commited on
Commit
585e159
·
verified ·
1 Parent(s): e92105a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -3,15 +3,22 @@ import pandas as pd
3
  import time
4
  import gtts
5
  import os
6
- from playsound import playsound
7
  import speech_recognition as sr
8
 
 
 
 
9
  # Function to convert text to speech
10
  def speak_text(text):
11
  tts = gtts.gTTS(text)
12
  filename = "temp_audio.mp3"
13
  tts.save(filename)
14
- playsound(filename)
 
 
 
 
15
  os.remove(filename)
16
 
17
  # Function to recognize speech input
 
3
  import time
4
  import gtts
5
  import os
6
+ import pygame
7
  import speech_recognition as sr
8
 
9
+ # Initialize pygame mixer
10
+ pygame.mixer.init()
11
+
12
  # Function to convert text to speech
13
  def speak_text(text):
14
  tts = gtts.gTTS(text)
15
  filename = "temp_audio.mp3"
16
  tts.save(filename)
17
+ pygame.mixer.music.load(filename)
18
+ pygame.mixer.music.play()
19
+ while pygame.mixer.music.get_busy():
20
+ time.sleep(0.1)
21
+ pygame.mixer.music.unload()
22
  os.remove(filename)
23
 
24
  # Function to recognize speech input