【问题标题】:How to silence specific words in an audio file using python?如何使用 python 使音频文件中的特定单词静音?
【发布时间】:2021-10-18 15:14:11
【问题描述】:

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

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

【问题讨论】:

    标签: python audio speech-recognition audio-processing audio-analysis


    【解决方案1】:

    这个答案显示how to get the timestamps of words。然后可以使用时间戳来使包含要静音的单词的部分静音。

    【讨论】:

    • 如果我 print(results) 它打印“[]”
    • 表示没有找到单词。检查您的输入音频,并尝试其他文件
    • 我尝试了几个音频文件并使用了“vosk-model-small-en-in-0.4”。还是同样的问题。
    • 我遇到了问题。 VOSK 未正确安装。我创建了一个新的虚拟环境并在那里运行它。非常感谢。
    猜你喜欢
    • 2021-05-22
    • 1970-01-01
    • 2018-06-03
    • 1970-01-01
    • 1970-01-01
    • 2013-10-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多