Amazon Polly + Google Home + Sonoff wifi [P018]





https://www.youtube.com/watch?v=IX2mUb73he8


GitHub : https://github.com/rdiot/rdiot-p018.git


* Parts

Google Home AI Speaker [B187]

Sonoff ITEAD WiFi Switch Module (ESP8266) [S198]

Amazon Polly TTS [P017]


* Contents

- Install AWS CLI in Raspberry Pi

wget https://s3.amazonaws.com/aws-cli/awscli-bundle.zip

$ unzip awscli-bundle.zip 

$ sudo ./install -i /usr/local/aws -b /usr/local/bin/aws


- Config AWS CLI

$ aws configure


- Java amazon polly development

 : maven : pom.xml : https://github.com/rdiot/rdiot-p018/blob/master/pom.xml

 : Source : https://github.com/rdiot/rdiot-p018/blob/master/PollyDemo.java

 : Binary : polly_sonoff.tar.gz

 : command.txt : ON or OFF 



- Sonoff Work with Google Home 

- How to connect Sonoff smart ewelink to Google Assistant

1) Tap Home control in Googlt Home App Menu

2) Uner Devices, tap the + icon in the bootom right. (add devices)

3) Tap Smart We Link 

4) Enter Your eWeLink account email/phone number. (need countrycode and account, password)

5) After Logging in successfully, it will display the device.




- Run java amazon polly application

$ java - jar polly-0.0.1-SNAPSHOT.jar 



Posted by RDIoT
|

Raspberry Pi Camera 5MP Night Version (SEN0184) [S280]






https://www.youtube.com/watch?v=HhDAtAHRuQ8


* Specs

Camera: 5 million pixels

Photosensitive Module: OV5647

Camera Parameters:

CCD size: 1/4 inches

Aperture (f): 1.8

Focal Length: 3.6MM (adjustable)

Diagonal: 75.7 degrees

Sensor best PIX: 1080p

4 Screw Holes

Can be used in a fixed position

3.3V external power supplies

Supports access to the infrared light or fill light

Dimension: 25mm x 24mm



* Contents

- Capture still image

$ raspistill -t 30000 -o rdiot.jpg


- Capture video

$ raspivid -t 10000 -o video.h264



- Capture Night Test



- Capture Day Test



- Download Capture File Sample : 



- Reference 

 : RASPICAM COMMANDS : https://www.raspberrypi.org/documentation/usage/camera/raspicam/README.md



'2) Sensor > Camera' 카테고리의 다른 글

UVC Camera Movie Monitoring [P006]  (0) 2017.03.03
UVC Camera Servo Motor Control [P006.1]  (0) 2017.01.07
Logitech HD WebCam C310 (C310) [S084]  (0) 2016.09.13
Samsung ARTIK 10 USB Camera [P010.7]  (0) 2016.08.31
Posted by RDIoT
|

Amazon Polly TTS(Text to Speech) [P017]





https://www.youtube.com/watch?v=1ehU_bueWdQ


GitHub : https://github.com/rdiot/rdiot-p017.git


* Specs

Amazon Polly is a service that turns text into lifelike speech, allowing you to create applications that talk, and build entirely new categories of speech-enabled products. Amazon Polly is a Text-to-Speech service that uses advanced deep learning technologies to synthesize speech that sounds like a human voice.


With dozens of lifelike voices across a variety of languages, you can select the ideal voice and build speech-enabled applications that work in many different countries.


* Contents

- Install AWS CLI in Raspberry Pi

wget https://s3.amazonaws.com/aws-cli/awscli-bundle.zip

$ unzip awscli-bundle.zip 

$ sudo ./install -i /usr/local/aws -b /usr/local/bin/aws


- config AWS CLI

$ aws configure


- java amazon polly library and text file


- run amazon polly application


- binary library download : polly.tar.gz


- maven dependency 

 : https://github.com/rdiot/rdiot-p017/blob/master/pom.xml

<dependency>

<groupId>com.amazonaws</groupId>

<artifactId>aws-java-sdk-polly</artifactId>

<version>1.11.77</version>

</dependency>

<!-- https://mvnrepository.com/artifact/com.googlecode.soundlibs/jlayer -->

<dependency>

<groupId>com.googlecode.soundlibs</groupId>

<artifactId>jlayer</artifactId>

<version>1.0.1-1</version>

</dependency>


- Souce Code

 : https://github.com/rdiot/rdiot-p017/blob/master/PollyDemo.java


package com.rdiot.polly;


import java.io.BufferedReader;

import java.io.FileInputStream;

import java.io.IOException;

import java.io.InputStream;

import java.io.InputStreamReader;


import com.amazonaws.ClientConfiguration;

import com.amazonaws.auth.DefaultAWSCredentialsProviderChain;

import com.amazonaws.regions.Region;

import com.amazonaws.regions.Regions;

import com.amazonaws.services.polly.AmazonPollyClient;

import com.amazonaws.services.polly.model.DescribeVoicesRequest;

import com.amazonaws.services.polly.model.DescribeVoicesResult;

import com.amazonaws.services.polly.model.OutputFormat;

import com.amazonaws.services.polly.model.SynthesizeSpeechRequest;

import com.amazonaws.services.polly.model.SynthesizeSpeechResult;

import com.amazonaws.services.polly.model.Voice;


import javazoom.jl.player.advanced.AdvancedPlayer;

import javazoom.jl.player.advanced.PlaybackEvent;

import javazoom.jl.player.advanced.PlaybackListener;


public class PollyDemo {


private final AmazonPollyClient polly;

private final Voice voice;

//private static final String SAMPLE = "Polly Test";

private static String SAMPLE;

public PollyDemo(Region region) {

// create an Amazon Polly client in a specific region

polly = new AmazonPollyClient(new DefaultAWSCredentialsProviderChain(), 

new ClientConfiguration());

polly.setRegion(region);

// Create describe voices request.

DescribeVoicesRequest describeVoicesRequest = new DescribeVoicesRequest().withLanguageCode("en-US");

// Synchronously ask Amazon Polly to describe available TTS voices.

DescribeVoicesResult describeVoicesResult = polly.describeVoices(describeVoicesRequest);

voice = describeVoicesResult.getVoices().get(0);

        

}

public static String roadLocalFile(String filepath) {

    String readFile= "";

    try {

        BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(filepath),"UTF-8"));

        String s;

        while ((s = in.readLine()) != null) {

            readFile+= s;

        }

        in.close();

    } catch (IOException e) {

        System.err.println(e);

        System.exit(1);

    }

 

    return readFile;

}


public InputStream synthesize(String text, OutputFormat format) throws IOException {

SynthesizeSpeechRequest synthReq = 

new SynthesizeSpeechRequest().withText(text).withVoiceId(voice.getId())

.withOutputFormat(format);

SynthesizeSpeechResult synthRes = polly.synthesizeSpeech(synthReq);


return synthRes.getAudioStream();

}


public static void main(String args[]) throws Exception {

SAMPLE = roadLocalFile("./text.txt");

//create the test class

PollyDemo helloWorld = new PollyDemo(Region.getRegion(Regions.AP_NORTHEAST_2));

//get the audio stream

InputStream speechStream = helloWorld.synthesize(SAMPLE, OutputFormat.Mp3);


//create an MP3 player

AdvancedPlayer player = new AdvancedPlayer(speechStream,

javazoom.jl.player.FactoryRegistry.systemRegistry().createAudioDevice());


player.setPlayBackListener(new PlaybackListener() {

@Override

public void playbackStarted(PlaybackEvent evt) {

System.out.println("#################################################################");

System.out.println("RD IoT Amazon Polly TTS");

System.out.println("#################################################################");

System.out.println("Playback started");

System.out.println("-----------------------------------------------------------------");

System.out.println("TTS : " + SAMPLE);

}

@Override

public void playbackFinished(PlaybackEvent evt) {

System.out.println("-----------------------------------------------------------------");

System.out.println("Playback finished");

System.out.println("#################################################################");

}

});

// play it!

player.play();

}


}




Posted by RDIoT
|