Anshya commited on
Commit
6a1f452
·
verified ·
1 Parent(s): 2026d73

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py CHANGED
@@ -26,6 +26,29 @@ iface = gr.Interface(
26
  outputs="text",
27
  title="Emotion & Sentiment Analyzer"
28
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
 
30
  iface.launch()
31
 
 
26
  outputs="text",
27
  title="Emotion & Sentiment Analyzer"
28
  )
29
+ import speech_recognition as sr
30
+
31
+ # Initialize recognizer
32
+ recognizer = sr.Recognizer()
33
+
34
+ # Load audio file
35
+ audio_file = sr.AudioFile("extracted_audio.wav")
36
+
37
+ from moviepy.editor import VideoFileClip
38
+
39
+ # Load video file
40
+ video = VideoFileClip("path_to_video.mp4")
41
+
42
+ # Extract audio
43
+ audio = video.audio
44
+ audio.write_audiofile("extracted_audio.wav")
45
+
46
+
47
+ # Recognize speech
48
+ with audio_file as source:
49
+ audio = recognizer.record(source)
50
+ text = recognizer.recognize_google(audio)
51
+ print("Transcribed Text:", text)
52
 
53
  iface.launch()
54