I am new to torchaudio, and I am trying to use StreamReader to get data from my microphone, but I cannot get it to start because it can’t access FFmpeg.
from torchaudio.io import StreamReader
streamer = StreamReader(
src='audio=@device_cm_{33D9A762-90C8-11D0-BD43-00A0C911CE86}\wave_{A531F508-ED15-42F3-A46F-9C8ADB26C05A}',
format='dshow',
)
for i in range(streamer.num_src_streams):
print(streamer.get_src_stream_info(i))
ImportError Traceback (most recent call last)
Cell In[2], line 4
1 import matplotlib.pyplot as plt
2 from torchaudio.io import StreamReader
----> 4 streamer = StreamReader(
5 src='audio=@device_cm_{33D9A762-90C8-11D0-BD43-00A0C911CE86}\wave_{A531F508-ED15-42F3-A46F-9C8ADB26C05A}',
6 format='dshow',
7 )
File d:\Python\torchaudio\.venv\Lib\site-packages\torio\io\_streaming_media_decoder.py:526, in StreamingMediaDecoder.__init__(self, src, format, option, buffer_size)
524 self._be = ffmpeg_ext.StreamingMediaDecoderFileObj(src, format, option, buffer_size)
525 else:
--> 526 self._be = ffmpeg_ext.StreamingMediaDecoder(os.path.normpath(src), format, option)
528 i = self._be.find_best_audio_stream()
529 self._default_audio_stream = None if i < 0 else i
File d:\Python\torchaudio\.venv\Lib\site-packages\torio\_extension\utils.py:25, in _LazyImporter.__getattr__(self, item)
24 def __getattr__(self, item):
---> 25 self._import_once()
26 return getattr(self.module, item)
File d:\Python\torchaudio\.venv\Lib\site-packages\torio\_extension\utils.py:39, in _LazyImporter._import_once(self)
37 def _import_once(self):
38 if self.module is None:
---> 39 self.module = self.import_func()
40 # Note:
41 # By attaching the module attributes to self,
42 # module attributes are directly accessible.
43 # This allows to avoid calling __getattr__ for every attribute access.
44 self.__dict__.update(self.module.__dict__)
File d:\Python\torchaudio\.venv\Lib\site-packages\torio\_extension\utils.py:143, in _init_ffmpeg()
141 def _init_ffmpeg():
142 ffmpeg_vers = _get_ffmpeg_versions()
--> 143 ext = _find_ffmpeg_extension(ffmpeg_vers)
144 ext.init()
145 if ext.get_log_level() > 8:
File d:\Python\torchaudio\.venv\Lib\site-packages\torio\_extension\utils.py:122, in _find_ffmpeg_extension(ffmpeg_vers)
120 _LG.debug("Failed to load FFmpeg%s extension.", ffmpeg_ver, exc_info=True)
121 continue
--> 122 raise ImportError(
123 f"Failed to intialize FFmpeg extension. Tried versions: {ffmpeg_vers}. "
124 "Enable DEBUG logging to see more details about the error."
125 )
ImportError: Failed to intialize FFmpeg extension. Tried versions: ['6', '5', '4', '']. Enable DEBUG logging to see more details about the error.
Is the error I get. I am on windows and the version I have installed for FFmpeg is 6.1.1.
I have tried to look this up but I cannot find anyone with a similar issue. I am on windows 10 too, any help would be appreciated.
Thank you.