LoginSignup
0
0

More than 1 year has passed since last update.

Docker上で音声ファイルを再生しようとしたら、"Error opening PCM device"と怒られた話

Posted at

環境

  • macOS
  • Docker
  • Python3.10

エラー文

root@43469b615ba0:/code# /usr/local/bin/python /code/voicevox.py
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5233:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM default
Traceback (most recent call last):
  File "/code/voicevox.py", line 69, in <module>
    play_obj = wave_obj.play()
  File "/usr/local/lib/python3.8/site-packages/simpleaudio/shiny.py", line 19, in play
    return play_buffer(self.audio_data, self.num_channels,
  File "/usr/local/lib/python3.8/site-packages/simpleaudio/shiny.py", line 60, in play_buffer
    play_id = _sa._play_buffer(audio_data, num_channels, bytes_per_sample,
_simpleaudio.SimpleaudioError: Error opening PCM device. -- CODE: -2 -- MSG: No such file or directory

エラーの詳細

サウンドインターフェースへアクセスできない
Dockerは仮想環境であり、その中では再生できないため、ホスト側のサウンドインターフェースを使わせる必要がある。

解決方法

macの場合はこの方法で解決した。
Dockerのメリットとして、ホストに関わらず動く特性がある。今回の方法はmacのみしか動作確認していないため、Windowsでも検証したい。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0