Skip to content

Commit

Permalink
reduce command output
Browse files Browse the repository at this point in the history
  • Loading branch information
xiongyihui committed May 23, 2018
1 parent c58d147 commit a4a583b
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 13 deletions.
2 changes: 1 addition & 1 deletion avs/interface/alerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import uuid

# prefer mpg123 player as it is more responsive than mpv and gstreamer
if os.system('which mpg123') == 0:
if os.system('which mpg123 >/dev/null') == 0:
from avs.player.mpg123_player import Player
else:
from avs.player import Player
Expand Down
2 changes: 1 addition & 1 deletion avs/interface/speech_synthesizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import logging

# prefer mpg123 player as it is more responsive than mpv and gstreamer
if os.system('which mpg123') == 0:
if os.system('which mpg123 >/dev/null') == 0:
from avs.player.mpg123_player import Player
else:
from avs.player import Player
Expand Down
2 changes: 1 addition & 1 deletion avs/mic/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

recorder_option = os.getenv('RECORDER', 'default').lower()

if recorder_option.find('pyaudio') >= 0 or os.system('which arecord') != 0:
if recorder_option.find('pyaudio') >= 0 or os.system('which arecord >/dev/null') != 0:
from pyaudio_recorder import Audio
else:
from alsa_recorder import Audio
Expand Down
3 changes: 2 additions & 1 deletion avs/mic/alsa_recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ def run(self):
'-f', 'S16_LE',
'-c', str(self.channels),
'-r', str(self.rate),
'-D', self.device_name
'-D', self.device_name,
'-q'
]
process = subprocess.Popen(cmd, stdout=subprocess.PIPE)

Expand Down
4 changes: 2 additions & 2 deletions avs/player/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
try:
from gstreamer_player import Player
except ImportError:
if os.system('which mpv') == 0:
if os.system('which mpv >/dev/null') == 0:
from mpv_player import Player
elif os.system('which mpg123') == 0:
elif os.system('which mpg123 >/dev/null') == 0:
from mpg123_player import Player
else:
raise ImportError('No player available, install one of the players: gstreamer, mpv and mpg123 first')
Expand Down
6 changes: 2 additions & 4 deletions avs/player/mpg123_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import threading
import subprocess

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

class Player(object):
Expand All @@ -30,7 +30,7 @@ def _run(self):
print('Playing {}'.format(self.audio))

master, slave = os.openpty()
self.process = subprocess.Popen(['mpg123', '-C', self.audio], stdin=master)
self.process = subprocess.Popen(['mpg123','-q', '-C', self.audio], stdin=master)
self.tty = slave

self.process.wait()
Expand All @@ -51,8 +51,6 @@ def play(self, uri):

self.state = 'PLAYING'

print('set play event')

def stop(self):
if self.process and self.process.poll() == None:
os.write(self.tty, 'q')
Expand Down
4 changes: 1 addition & 3 deletions avs/player/mpv_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import threading
import subprocess

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


Expand Down Expand Up @@ -49,8 +49,6 @@ def play(self, uri):

self.state = 'PLAYING'

print('set play event')

def stop(self):
if self.process and self.process.poll() == None:
os.write(self.tty, 'q')
Expand Down

0 comments on commit a4a583b

Please sign in to comment.