9and3r / mopidy-ttsgpio Goto Github PK
View Code? Open in Web Editor NEWExtension to control mopidy without screen
License: Apache License 2.0
Extension to control mopidy without screen
License: Apache License 2.0
Hey there, great Mopidy extension. Was about to program this on my own - but then found this repo!
I was planning to add a poti to my Raspberry Pi to control the volume. Usually I would use it together with a ADC (e.g. MCP3008) to convert the analog to a digital signal which the Raspberry Pi is able to understand.
Would this be possible? If so, any suggestions of how to do this? Is there a 1) possible and 2) preferred way of how to integrate this into your extension?
Could you maybe support a lcd too and in that case disable the TTS. So your code would cover all the possibilities :)
I get an error when Mopidy tries to start ttsgpio:
Aug 11 15:30:22 pirateradio mopidy[476]: INFO [MainThread] mopidy.__main__ Starting Mopidy 3.0.2
Aug 11 15:30:22 pirateradio mopidy[476]: INFO [MainThread] mopidy.config Loading config from builtin defaults
Aug 11 15:30:22 pirateradio mopidy[476]: INFO [MainThread] mopidy.config Loading config from file:///usr/share/mopidy/conf.d/mopidy.conf
Aug 11 15:30:22 pirateradio mopidy[476]: INFO [MainThread] mopidy.config Loading config from file:///etc/mopidy/mopidy.conf
Aug 11 15:30:22 pirateradio mopidy[476]: INFO [MainThread] mopidy.config Loading config from command line options
Aug 11 15:30:25 pirateradio mopidy[476]: INFO [MainThread] mopidy.__main__ Enabled extensions: stream, m3u, http, file, spotify, softwaremixer, alsamixer, iris, ttsgpio
Aug 11 15:30:25 pirateradio mopidy[476]: INFO [MainThread] mopidy.__main__ Disabled extensions: none
Aug 11 15:30:28 pirateradio mopidy[476]: INFO [MainThread] mopidy.commands Starting Mopidy mixer: SoftwareMixer
Aug 11 15:30:28 pirateradio mopidy[476]: INFO [MainThread] mopidy.commands Mixer volume set to 35
Aug 11 15:30:28 pirateradio mopidy[476]: INFO [MainThread] mopidy.commands Starting Mopidy audio
Aug 11 15:30:28 pirateradio mopidy[476]: INFO [MainThread] mopidy.commands Starting Mopidy backends: FileBackend, M3UBackend, StreamBackend, SpotifyBackend
Aug 11 15:30:28 pirateradio mopidy[476]: INFO [Audio-2] mopidy.audio.actor Audio output set to "autoaudiosink"
Aug 11 15:30:43 pirateradio mopidy[476]: INFO [SpotifyEventLoop] mopidy_spotify.backend Logged in to Spotify in online mode
Aug 11 15:30:43 pirateradio mopidy[476]: INFO [SpotifyBackend-6] mopidy_spotify.web Logged into Spotify Web API as thomasdeutsch
Aug 11 15:38:41 pirateradio mopidy[476]: INFO [SpotifyBackend-6] mopidy_spotify.playlists Refreshed 284 Spotify playlists
Aug 11 15:38:41 pirateradio mopidy[476]: INFO [MainThread] mopidy.commands Starting Mopidy core
Aug 11 15:38:41 pirateradio mopidy[476]: INFO [MainThread] mopidy.commands Starting Mopidy frontends: TtsGpio, IrisFrontend, HttpFrontend
Aug 11 15:38:42 pirateradio mopidy[476]: ERROR [MainThread] mopidy.commands Got un-handled exception from TtsGpio
Aug 11 15:38:42 pirateradio mopidy[476]: Traceback (most recent call last):
Aug 11 15:38:42 pirateradio mopidy[476]: File "/usr/lib/python3/dist-packages/mopidy/commands.py", line 241, in _actor_error_handling
Aug 11 15:38:42 pirateradio mopidy[476]: yield
Aug 11 15:38:42 pirateradio mopidy[476]: File "/usr/lib/python3/dist-packages/mopidy/commands.py", line 438, in start_frontends
Aug 11 15:38:42 pirateradio mopidy[476]: frontend_class.start(config=config, core=core)
Aug 11 15:38:42 pirateradio mopidy[476]: File "/usr/lib/python3/dist-packages/pykka/_actor.py", line 91, in start
Aug 11 15:38:42 pirateradio mopidy[476]: obj = cls(*args, **kwargs)
Aug 11 15:38:42 pirateradio mopidy[476]: File "/usr/local/lib/python3.7/dist-packages/mopidy_ttsgpio/frontend.py", line 21, in __init__
Aug 11 15:38:42 pirateradio mopidy[476]: self.main_menu = MainMenu(self)
Aug 11 15:38:42 pirateradio mopidy[476]: File "/usr/local/lib/python3.7/dist-packages/mopidy_ttsgpio/main_menu.py", line 13, in __init__
Aug 11 15:38:42 pirateradio mopidy[476]: self.elements = [PlaylistMenu(frontend), 'exit mopidy']
Aug 11 15:38:42 pirateradio mopidy[476]: File "/usr/local/lib/python3.7/dist-packages/mopidy_ttsgpio/playlist_menu.py", line 12, in __init__
Aug 11 15:38:42 pirateradio mopidy[476]: self.reload_playlists()
Aug 11 15:38:42 pirateradio mopidy[476]: File "/usr/local/lib/python3.7/dist-packages/mopidy_ttsgpio/playlist_menu.py", line 25, in reload_playlists
Aug 11 15:38:42 pirateradio mopidy[476]: for playlist in self.frontend.core.playlists.playlists.get():
Aug 11 15:38:42 pirateradio mopidy[476]: File "/usr/lib/python3/dist-packages/pykka/_proxy.py", line 219, in __getattr__
Aug 11 15:38:42 pirateradio mopidy[476]: raise AttributeError('{} has no attribute {!r}'.format(self, name))
Aug 11 15:38:42 pirateradio mopidy[476]: AttributeError: <ActorProxy for Core (urn:uuid:b975feb9-a04b-4d1d-9eae-36edd319765c), attr_path=('playlists',)> has no attribute 'playlists'
Aug 11 15:38:42 pirateradio mopidy[476]: INFO [IrisFrontend-10] mopidy_iris.core Starting Iris 3.51.0
Aug 11 15:38:42 pirateradio mopidy[476]: INFO [HttpFrontend-12] mopidy.http.actor HTTP server running at [::]:6680
Aug 11 15:38:42 pirateradio mopidy[476]: INFO [MainThread] mopidy.commands Starting GLib mainloop
This is how my current config looks like, anything else is default:
[core]
cache_dir = /var/cache/mopidy
config_dir = /etc/mopidy
data_dir = /var/lib/mopidy
[audio]
mixer = software
mixer_volume = 35
output = autoaudiosink
[iris]
enabled = true
country = CH
locale = de_CH
[ttsgpio]
enabled = true
#debug_gpio_simulate = false
pin_button_main = 6
pin_button_next = 5
pin_button_previous = 13
pin_button_vol_up = 16
pin_button_vol_down = 26
pin_play_led = 20
[spotify]
enabled = true
username = XXXXXXXXXXXXXXXX
password = XXXXXXXXXXXXXXXX
client_id = XXXXXXXXXXXXXXXX
client_secret = XXXXXXXXXXXXXXXX
[http]
enabled = true
hostname = ::
port = 6680
[m3u]
#playlists_dir = /var/lib/mopidy/playlists
[softwaremixer]
enabled = true
[file]
enabled = true
media_dirs = /var/lib/mopidy/media
[alsamixer]
enabled = true
card = 0
control = PCM
Hi.
It will by nice to have adidtional options for the volume of speech
It may be offset +/- of main volume which we can easily change via buttons, web or mpd clients.
My Problem:
->
sudo mopidy
INFO Starting Mopidy 2.0.0
ERROR Failed to load extension ttsgpio: No module named pygst
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/mopidy/ext.py", line 202, in load_extensions
extension_class = entry_point.load(require=False)
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2190, in load
['name'])
File "/usr/local/lib/python2.7/dist-packages/mopidy_ttsgpio/init.py", line 8, in
import pygst
ImportError: No module named pygst
INFO Loading config from builtin defaults
INFO Loading config from /root/.config/mopidy/mopidy.conf
INFO Loading config from command line options
INFO Enabled extensions: mpd, http, stream, m3u, softwaremixer, file, musicbox_webclient, websettings, tunein
INFO Disabled extensions: local
WARNING Found local configuration errors, the extension has been automatically disabled:
WARNING local/media_dir must be set.
WARNING Please fix the extension configuration errors or disable the extensions to silence these messages.
INFO Starting Mopidy mixer: SoftwareMixer
INFO Starting Mopidy audio
INFO Starting Mopidy backends: TuneInBackend, StreamBackend, M3UBackend, FileBackend
INFO Audio output set to "autoaudiosink"
INFO Starting Mopidy core
INFO Starting Mopidy frontends: MpdFrontend, HttpFrontend
INFO MPD server running at [::ffff:127.0.0.1]:6600
INFO HTTP server running at [::ffff:127.0.0.1]:6680
INFO Starting GLib mainloop
Hi,
on my PI I very often get fake long pressed buttons. It happens when I connect devices, like usb flash drive. I analyzed issue. To my mind, the main reason is electromagnetic interference. The signal causes GPIO.add_event_detect and after that very quickly set GPIO.input(channel) == 1. The self.down_time_previous has previos value (from last call of function) - as result we get long press button. I changed code (ex: volume down button):
longpress_time = 1
longpress_time2 = 5
def vol_down(self, channel):
if GPIO.input(channel) == 1:
if self.down_time_vol_down + longpress_time > time.time():
self.frontend.input({'key': 'volume_down', 'long': False})
elif self.down_time_vol_down + longpress_time2 > time.time():
self.frontend.input({'key': 'volume_down', 'long': True})
else:
self.down_time_vol_down = time.time()
Now I don't get fake long pressed buttons. Please, check it and fix.
hey,
im Building a vintage Radio with a raspi and mopidy runnig.
i try to use the existent Hardware Buttons/layout.
is it possible to change or choose between two Playlists via your gpio plugin?
or could you give me a hint on to to adapt your plugin or customize it?
thanks in advance. and great work by the way!
Mopidy-TtsGpio is using the internal function mopidy.utils.process.exit_process()
in one place:
As this method is internal and not supposed to be used by Mopidy extensions, I recommend using other means for stopping Mopidy, similar to your methods for shutting down the device with os.system()
.
If mopidy/mopidy#1173 is merged, Mopidy-TtsGpio will break with Mopidy 1.1.
Change TTS service used.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.