Rhueue commited on
Commit
7c58da8
·
1 Parent(s): 7cd88dd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -15
app.py CHANGED
@@ -13,14 +13,20 @@ def transcribe_audio(audio_file):
13
  except sr.UnknownValueError:
14
  return ""
15
 
16
- def filter_words(input_text, transcribed_text):
17
- transcribed_words = transcribed_text.split()
18
- filtered_text = input_text
19
- for word in transcribed_words:
20
- filtered_text = filtered_text.replace(word, "")
21
- return filtered_text
22
 
23
- st.title("Voice Cloning Word Filter")
 
 
 
 
 
 
 
 
24
 
25
  uploaded_audio = st.file_uploader("Upload an audio file", type=["wav", "mp3", "ogg"])
26
  input_text = st.text_area("Enter input text")
@@ -28,16 +34,12 @@ input_text = st.text_area("Enter input text")
28
  if uploaded_audio is not None:
29
  st.audio(uploaded_audio, format="audio/wav")
30
 
31
- if st.button("Transcribe and Filter"):
32
  if uploaded_audio is not None:
33
- transcribed_text = transcribe_audio(uploaded_audio)
34
- filtered_text = filter_words(input_text, transcribed_text)
35
- st.subheader("Transcribed Text:")
36
- st.write(transcribed_text)
37
- st.subheader("Filtered Output Text:")
38
  st.write(filtered_text)
39
 
40
  st.write(
41
- "Note: This is a simple demonstration of filtering words from an audio transcript. The accuracy of word filtering "
42
- "depends on the quality of the audio and the performance of the ASR engine."
43
  )
 
13
  except sr.UnknownValueError:
14
  return ""
15
 
16
+ def filter_audio(audio_file, input_text):
17
+ transcribed_text = transcribe_audio(audio_file)
18
+ transcribed_words = set(transcribed_text.split())
19
+ input_words = set(input_text.split())
 
 
20
 
21
+ # Retain only the words in the transcribed text that match the input text
22
+ filtered_words = transcribed_words.intersection(input_words)
23
+
24
+ # Create a new transcription with the filtered words
25
+ filtered_transcription = " ".join(filtered_words)
26
+
27
+ return filtered_transcription
28
+
29
+ st.title("Audio Word Filter")
30
 
31
  uploaded_audio = st.file_uploader("Upload an audio file", type=["wav", "mp3", "ogg"])
32
  input_text = st.text_area("Enter input text")
 
34
  if uploaded_audio is not None:
35
  st.audio(uploaded_audio, format="audio/wav")
36
 
37
+ if st.button("Filter Audio"):
38
  if uploaded_audio is not None:
39
+ filtered_text = filter_audio(uploaded_audio, input_text)
40
+ st.subheader("Filtered Audio Transcript:")
 
 
 
41
  st.write(filtered_text)
42
 
43
  st.write(
44
+ "Note: This app transcribes the uploaded audio and filters it to retain only the words mentioned in the input text."
 
45
  )