Skip to content

Commit

Permalink
reorganize player, prefer mpg123 to play local mp3
Browse files Browse the repository at this point in the history
  • Loading branch information
xiongyihui committed Mar 28, 2018
1 parent 9472ca8 commit d459acd
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 12 deletions.
6 changes: 5 additions & 1 deletion avs/interface/alerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
from threading import Timer, Event
import uuid

from avs.player import Player
# prefer mpg123 player as it is more responsive than mpv and gstreamer
if os.system('which mpg123') == 0:
from avs.player.mpg123_player import Player
else:
from avs.player import Player


class Alerts(object):
Expand Down
1 change: 1 addition & 0 deletions avs/interface/audio_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ def PlaybackStutterFinished(self):

def PlaybackFinished(self):
self.state = 'FINISHED'
logger.info('playback is finished')

event = {
"header": {
Expand Down
6 changes: 5 additions & 1 deletion avs/interface/speech_synthesizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
import hashlib
import logging

from avs.player import Player
# prefer mpg123 player as it is more responsive than mpv and gstreamer
if os.system('which mpg123') == 0:
from avs.player.mpg123_player import Player
else:
from avs.player import Player

logger = logging.getLogger('SpeechSynthesizer')

Expand Down
15 changes: 11 additions & 4 deletions avs/player.py → avs/player/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# -*- coding: utf-8 -*-

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

import os

Expand All @@ -12,11 +16,14 @@
from mpg123_player import Player
elif player_option.find('single') >= 0:
from single_gstreamer_player import Player
else:
elif player_option.find('gstreamer') >= 0:
from gstreamer_player import Player
else:
if os.system('which mpv') == 0:
from mpv_player import Player
else:
from gstreamer_player import Player


__all__ = ['Player']



File renamed without changes.
2 changes: 2 additions & 0 deletions avs/mpg123_player.py → avs/player/mpg123_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import threading
import subprocess

if os.system('which mpg123') != 0:
ImportError('mpg123 not found, install it first')

class Player(object):
def __init__(self):
Expand Down
3 changes: 3 additions & 0 deletions avs/mpv_player.py → avs/player/mpv_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
import threading
import subprocess

if os.system('which mpv') != 0:
raise ImportError('mpv not found, install it first')


class Player(object):
def __init__(self):
Expand Down
File renamed without changes.
12 changes: 6 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@

from setuptools import setup, find_packages

with open('README.rst') as readme_file:
readme = readme_file.read()

with open('HISTORY.rst') as history_file:
history = history_file.read()
with open('README.md') as f:
long_description = f.read()


requirements = [
'click',
Expand All @@ -29,9 +28,10 @@

setup(
name='avs',
version='0.1.1',
version='0.2.0',
description="Python implementation of Alexa Voice Service App",
long_description=readme + '\n\n' + history,
long_description=long_description,
long_description_content_type='text/markdown',
author="Yihui Xiong",
author_email='[email protected]',
url='https://github.com/respeaker/avs',
Expand Down

0 comments on commit d459acd

Please sign in to comment.