如何使用 python 使音频文件中的特定单词静音?

How to silence specific words in an audio file using python?

我想将音频文件中的特定单词静音。我有一个应该静音的单词列表。我已尝试使用此代码将音频文件转换为文本,但如何获取每个单词的时间范围以便将它们静音?

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!") 

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