Skip to content

Commit

Permalink
prefer gstreamer as audio player as it works better on raspberry pi
Browse files Browse the repository at this point in the history
  • Loading branch information
xiongyihui committed Mar 28, 2018
1 parent 929cd67 commit fe653ee
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Python Alexa Voice Service App

Choose a player from `mpv`, `mpg123` and gstreamer.
`SpeechSynthesizer` and `Alerts` prefer `mpg123` as it is more responsive.
`AudioPlayer` likes `mpv` > gstreamer > `mpg123` as `mpv` and gstreamer support more audio format. We can also specify the player of `AudioPlayer` using the environment variable `PLAYER`.
`AudioPlayer` likes gstreamer > `mpv` > `mpg123`. Gstreamer supports more audio format and works well on raspberry pi. We can also specify the player of `AudioPlayer` using the environment variable `PLAYER`.

* one of mpg123, mpv and gstreamer 1.0
* python-pyaudio
Expand Down
13 changes: 9 additions & 4 deletions avs/player/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

"""Player
support mpv, mpg123 and gstreamer 1.0
It prefers mpv if it is available, otherwise use gstreamer 1.0
It likes gstreamer 1.0 > mpv > mpg123
We can specify a player using environment variable PLAYER (mpv, mpg123, gstreamer, single_gstreamer)
"""

Expand All @@ -19,10 +19,15 @@
elif player_option.find('gstreamer') >= 0:
from gstreamer_player import Player
else:
if os.system('which mpv') == 0:
from mpv_player import Player
else:
try:
from gstreamer_player import Player
except ImportError:
if os.system('which mpv') == 0:
from mpv_player import Player
elif os.system('which mpg123') == 0:
from mpg123_player import Player
else:
raise ImportError('No player available, install gstreamer, mpv or mpg123 first')


__all__ = ['Player']
Expand Down

0 comments on commit fe653ee

Please sign in to comment.