/black-mirror

A voice controlled smart mirror powered by Raspberry Pi3 and AndroidThings.

Primary LanguageJavaMIT LicenseMIT

Black Mirror

A voice controlled smart mirror powered by Raspberry Pi3B+ and AndroidThings. Mirror is capable to display or hide widgets such as weather, news, time, calendar when the correct voice command is given.

Buy Me a Coffee at ko-fi.com

Commands

At the moment Black Mirror supporting commands in polish language only. If you would like to change the language, see the setup section below. Mirror listen the command only after "wakeup mirror" keyword spotted, this action will be indicated by mic animation.

  1. Showing/hiding weather widget:

"Pokaż pogodę dla miasta (Lokalizacja)"
"Zamknij widok pogody"

  1. Showing/hiding news widget.

"Pokaż wiadomości ze świata"
"Pokaz wiadomości z Polsatu"
"Pokaż wiadomości z TVNu"
"Zamknij widok wiadomości"

  1. Showing/hiding time widget.

"Pokaż czas dla kraju (Lokalizacja)"
"Zamknij/Ukryj zegar"

  1. Showing/hiding/changing calendar month.

"Pokaż kalendarz"
"Pokaż kolejny miesiąc"
"Pokaż poprzedni miesiąc"
"Zamknij widok kalendarza"

Setup

API keys

Paste your api keys in gradle.properties. You need to register in OpenWeatherMap, TimeZoneDb, GoogleGeoApi to obtain api keys. It's completly free.

Google Cloud Speech Cloud Credentials

To work with google speech recognition you need credentials.json file placed in /res/raw directory. More info at: https://github.com/GoogleCloudPlatform/android-docs-samples/tree/master/speech/Speech

Keyword changing

If you want to change default keyword "wakeup mirror", you should change line in PocketSphinx.java (line:24)

private static final String ACTIVATION_KEYPHRASE = "wakeup mirror";

Language change

  1. Set your language code in SpeechService.java (line: 262)
 mRequestObserver.onNext(StreamingRecognizeRequest.newBuilder()
                .setStreamingConfig(StreamingRecognitionConfig.newBuilder()
                        .setConfig(RecognitionConfig.newBuilder()
                                // Change this line
                                .setLanguageCode("pl-PL")
                                .setEncoding(RecognitionConfig.AudioEncoding.LINEAR16)
                                .setSampleRateHertz(sampleRate)
                                .build())
  1. Change all vocabularies in TextCommandInterpreter. For example:
private final ArrayList<String> countryVocabulary = new ArrayList<>(Arrays.asList("kraj", "kraju", "krajowi", "krajom"));

change to:

private final ArrayList<String> countryVocabulary = new ArrayList<>(Arrays.asList("country", "countries", "land", "state"));

Run on android smartphone

Comment or delete this in AndroidManifest.xml

<intent-filter>
     <action android:name="android.intent.action.MAIN"/>
     <!-- Comment this <category android:name="android.intent.category.IOT_LAUNCHER"/> -->
     <category android:name="android.intent.category.DEFAULT"/>
</intent-filter>

Permissions

You need to remember to grant permission via adb or android settings for:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.RECORD_AUDIO"/>

Pictures

Welcome screen Welcome screen Welcome screen

Video

YouTube video

Hardware

  • Raspberry Pi3
  • Anbes Super Mini New High-Quality Sound USB 2.0 Microphone Audio Adapter (works with AndroidThings out of the box)
  • Compaq 17' 4:3 LCD Display

License MIT

MIT License

Copyright (c) 2017 Przemek

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.