0

This is my code where I want to read an audio file from url. This code gives me an error.

import speech_recognition as sr
r = sr.Recognizer()
audio = sr.AudioFile('http://www.wavsource.com/snds_2018-06-03_5106726768923853/people/comedians/carlin_logic.wav')
with audio as source:
   audio = r.record(source)

Error:

IOError: [Errno 22] invalid mode ('rb') or filename: 'http://www.wavsource.com/snds_2018-06-03_5106726768923853/people/comedians/carlin_logic.wav'

I also have another piece of code, i want help in reading audio file from url here also.

from watson_developer_cloud import SpeechToTextV1
file = 'http://www.wavsource.com/snds_2018-06-03_5106726768923853/people/comedians/carlin_logic.wav'
with open(file,
             'rb') as audio_file:
 data = speech_to_text.recognize(
      audio=audio_file,
      countinuous = True,
      content_type='audio/wav',
      interim_results = True,
      smart_formatting = True,
      timestamps=True,
      speaker_labels = True)

Error:

IOError: [Errno 22] invalid mode ('rb') or filename: 'http://www.wavsource.com/snds_2018-06-03_5106726768923853/people/comedians/carlin_logic.wav'

0 Answers0