0

Is there a way to detect pauses while taking input from the microphone in python? I have a sample code that uses speech-recognition google API to convert speech to text using a microphone of the laptop, but I'm looking for a way to detect pauses in speech simultaneously.

// Code for speech to text:

    import speech_recognition as sr
    import pyaudio
    r = sr.Recognizer()
    with sr.Microphone() as source:
      r.adjust_for_ambient_noise(source)
      data = r.record(source, duration=20)
      text = r.recognize_google(data,language='en')
      print(text)
  • Do you actually trying to `pause` speech recognition if user say to pause? –  Jan 11 '21 at 08:24
  • Suppose the other party has been talking for a couple of sentences and has paused while talking. I need to get that pause transcripted in the text generated like --pause-- indicating silence or pause – astha jain Jan 11 '21 at 08:29
  • You meant, i am talking for a moment. Then, suddenly i said `pause`. you wanna stop the speech recognizer that moment, don't you? –  Jan 11 '21 at 08:49
  • 1
    No, you don't have to explicitly mention the word " pause" it should detect pause whenever there is silence in the speech. Holistically, I am building an AI which pops up suggestions like "really??" or " uh-oh" which are equivalent to a verbal smile of encouragement whenever there is a pause in the speech. So, when speech is being converted to text it should record the "pause" also in the transcript generated for me to process it later for popping up suggestions. – astha jain Jan 11 '21 at 08:56

0 Answers0