KhaqanNasir commited on
Commit
156b0ac
·
verified ·
1 Parent(s): a78f248

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -11
app.py CHANGED
@@ -1,13 +1,10 @@
1
  import streamlit as st
2
- import os
3
  import random
4
  import time
5
  from transformers import pipeline
6
- from pydub import AudioSegment
7
  import speech_recognition as sr
8
  from streamlit_webrtc import webrtc_streamer, VideoTransformerBase
9
  import numpy as np
10
- import wave
11
  import io
12
 
13
  # Streamlit Configuration
@@ -72,15 +69,9 @@ if st.button("Start Interview"):
72
  st.write(f"**Question {st.session_state.question_index + 1}:** {current_question}")
73
  st.write("🎤 Please record your answer using the microphone.")
74
 
75
- # Live voice recording with streamlit-webrtc
76
- audio_recorder = webrtc_streamer(
77
- key="audio-recorder",
78
- video_transformer_factory=VideoTransformerBase,
79
- audio_source=True, # Enable audio recording
80
- sendback_audio=True # Send back recorded audio
81
- )
82
 
83
- # Check if the user has recorded audio
84
  if audio_recorder and audio_recorder.audio:
85
  audio_data = audio_recorder.audio
86
  audio_bytes = audio_data.tobytes() # Convert audio to byte format for processing
 
1
  import streamlit as st
 
2
  import random
3
  import time
4
  from transformers import pipeline
 
5
  import speech_recognition as sr
6
  from streamlit_webrtc import webrtc_streamer, VideoTransformerBase
7
  import numpy as np
 
8
  import io
9
 
10
  # Streamlit Configuration
 
69
  st.write(f"**Question {st.session_state.question_index + 1}:** {current_question}")
70
  st.write("🎤 Please record your answer using the microphone.")
71
 
72
+ # Initialize WebRTC for live audio capture
73
+ audio_recorder = webrtc_streamer(key="audio-recorder", video_transformer_factory=VideoTransformerBase)
 
 
 
 
 
74
 
 
75
  if audio_recorder and audio_recorder.audio:
76
  audio_data = audio_recorder.audio
77
  audio_bytes = audio_data.tobytes() # Convert audio to byte format for processing