0

I want to mute specific words in audio files. I have a list of words that should be muted. I have tried converting the audio file to text using this code but how can I get the time frame of each word so I can mute them?

import speech_recognition as sr 
import moviepy.editor as mp

r = sr.Recognizer()

audio = sr.AudioFile("Welcome.wav")
print(audio)

with audio as source:
  audio_file = r.record(source)
  print(audio_file)

try:
        # using google speech recognition
        text = r.recognize_google(audio_file)
        print('Converting audio transcripts into text ...')
        print(text)
     
except:
         print('Sorry.. run again...')

# exporting the result 
with open('recognized.txt',mode ='w') as file: 
   file.write("Recognized Speech:") 
   file.write("\n") 
   file.write(text) 
   print("ready!") 
4

1 回答 1

1

这个答案显示了如何获取 words 的时间戳。然后可以使用时间戳来使包含要静音的单词的部分静音。

于 2021-08-18T00:50:06.840 回答