Browse Source

Merge pull request #46 from kalliope-project/dev

Dev on master with Rpi review and test
Nicolas Marcq 8 years ago
parent
commit
c3240ea1ed

+ 111 - 0
Docs/RPi.md

@@ -0,0 +1,111 @@
+# Raspberry Pi configuration
+
+This documentation deals with the special configuration needed for get kalliope working on a RPi.
+
+## Packages
+
+On a Raspberry Pi, pulseaudio is not installed by default
+```
+sudo apt-get install pulseaudio pulseaudio-utils
+```
+
+Start the pulseaudio server
+```
+pulseaudio -D
+```
+
+## Microphone configuration
+
+Get your output card
+```
+aplay -l
+```
+
+Output example with a USB headset connected
+```
+**** List of PLAYBACK Hardware Devices ****
+card 0: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA]
+  Subdevices: 7/8
+  Subdevice #0: subdevice #0
+  Subdevice #1: subdevice #1
+  Subdevice #2: subdevice #2
+  Subdevice #3: subdevice #3
+  Subdevice #4: subdevice #4
+  Subdevice #5: subdevice #5
+  Subdevice #6: subdevice #6
+  Subdevice #7: subdevice #7
+card 0: ALSA [bcm2835 ALSA], device 1: bcm2835 ALSA [bcm2835 IEC958/HDMI]
+  Subdevices: 1/1
+  Subdevice #0: subdevice #0
+card 1: Headset [Logitech USB Headset], device 0: USB Audio [USB Audio]
+  Subdevices: 0/1
+  Subdevice #0: subdevice #0
+```
+
+Here, we can see that we have 
+- the analog audio (where the jack is connected) on the card 0 and device 1
+- usb audio on card 1 and device 1
+
+
+Get your input (microphone card)
+```
+arecord -l
+```
+
+Output example with a USB headset connected
+```
+**** List of CAPTURE Hardware Devices ****
+card 1: Headset [Logitech USB Headset], device 0: USB Audio [USB Audio]
+  Subdevices: 0/1
+  Subdevice #0: subdevice #0
+```
+
+Here we can see that we have one peripheral on card 1 and device 0
+
+Now, we create a configuration file that will do apply the following configuration:
+- output audio (what Kalliope say) on the analog audio (via speakers connected to the jack)
+- input audio (what we say to Kalliope) on the USB microphone
+
+Create a file in `/home/pi/.asoundrc` with the content bellow
+```
+pcm.!default {
+   type asym
+   playback.pcm {
+     type plug
+     slave.pcm "hw:1,0"
+   }
+   capture.pcm {
+     type plug
+     slave.pcm "hw:1,0"
+   }
+}
+```
+
+Where `playback.pcm` is the output audio and the `capture.pcm` is the input audio.
+
+Restart alsa to apply changes
+```
+sudo /etc/init.d/alsa-utils restart
+```
+
+Do not forget to test recording your voice:
+
+Capture audio from your microphone
+```
+rec test.wav
+```
+
+Then play the recorded audio file
+```
+mplayer test.wav
+```
+
+
+## HDMI / Analog audio
+
+By default the audio stream will get out by HDMI if something is plugged to this port.
+Check the [official documentation](https://www.raspberrypi.org/documentation/configuration/audio-config.md) to switch from HDMI to analog.
+
+```
+sudo raspi-config
+```

+ 3 - 0
Docs/dev_env_install.md

@@ -4,6 +4,7 @@ This documentation aims at explaining step by step manual deployment of Kalliope
 
 Tested env
 - Ubuntu 16.04
+- Raspbian Jessie 
 
 
 
@@ -42,3 +43,5 @@ Install libs
 ```
 sudo pip install -r install/files/python_requirements.txt
 ```
+
+If you are running kalliope on a Raspberry Pi, you must perform some other step by [following the dedicated documentation](RPi.md).

+ 1 - 0
Docs/microphone_rpi.md

@@ -0,0 +1 @@
+# Tested microphone on Rpi

+ 1 - 0
README.md

@@ -22,6 +22,7 @@ Kalliope is easy-peasy to use, see the hello world
 
 - [Automated installation](Docs/automated_install.md)
 - [Manual installation for developement](Docs/dev_env_install.md)
+- [Raspberry Pi configuration](Docs/RPi.md)
 
 ## Usage
 

+ 4 - 1
core/Models/Settings.py

@@ -1,4 +1,5 @@
 from core.Models import Singleton
+import platform
 
 
 @Singleton
@@ -19,7 +20,8 @@ class Settings(object):
                  random_wake_up_sounds=None,
                  triggers=None,
                  rest_api=None,
-                 cache_path=None):
+                 cache_path=None,
+                 machine=None):
 
         self.default_tts_name = default_tts_name
         self.default_stt_name = default_stt_name
@@ -32,3 +34,4 @@ class Settings(object):
         self.rest_api = rest_api
         self.cache_path = cache_path
         self.is_loaded = False
+        self.machine = platform.machine()   # can be x86_64 or armv7l

+ 4 - 0
core/TTS/TTSModule.py

@@ -58,6 +58,10 @@ class TTSModule(object):
         # load settings
         self.settings = SettingLoader.get_settings()
 
+        # create the path in the tmp folder
+        base_path = os.path.join(self.settings.cache_path, self.tts_caller_name, self.language, self.voice)
+        FileManager.create_directory(base_path)
+
         logger.debug("Class TTSModule called from module %s, cache: %s, language: %s, voice: %s" % (self.tts_caller_name,
                                                                                              self.cache,
                                                                                              self.language,

+ 5 - 3
neurons/systemdate/systemdate.py

@@ -7,9 +7,11 @@ class Systemdate(NeuronModule):
     def __init__(self, **kwargs):
         # get the cache if set by the user, if not, set it to false as it is not necessary
         cache = kwargs.get('cache', None)
-        if cache is None:
-            cache = False
-        super(Systemdate, self).__init__(cache=cache, **kwargs)
+        if cache is not None:
+            kwargs["cache"] = cache
+        else:
+            kwargs["cache"] = False
+        super(Systemdate, self).__init__(**kwargs)
 
         # local time and date
         hour = time.strftime("%H")          # Hour (24-hour clock) as a decimal number [00,23].

BIN
trigger/snowboy/armv7l/_snowboydetect.so


+ 5 - 4
trigger/snowboy/snowboydetect.py

@@ -3,19 +3,20 @@
 #
 # Do not make changes to this file unless you know what you are doing--modify
 # the SWIG interface file instead.
+from core.ConfigurationManager import SettingLoader
+from sys import version_info
 
+settings = SettingLoader.get_settings()
+module_file_path = "%s/_snowboydetect" % settings.machine
 
 
-
-
-from sys import version_info
 if version_info >= (2, 6, 0):
     def swig_import_helper():
         from os.path import dirname
         import imp
         fp = None
         try:
-            fp, pathname, description = imp.find_module('_snowboydetect', [dirname(__file__)])
+            fp, pathname, description = imp.find_module(module_file_path, [dirname(__file__)])
         except ImportError:
             import _snowboydetect
             return _snowboydetect

+ 0 - 0
trigger/snowboy/_snowboydetect.so → trigger/snowboy/x86_64/_snowboydetect.so