Amazons echo speaker

Amazons Echo speaker can now read you movie times and live NFL scores



Another week, another remarkably useful Amazon Echo update. This time around, Amazon is giving its voice-powered Alexa assistant, which powers the Echo speaker, the ability to read off movie times and NFL scores. Alexa will even fetch updates to live games, so you’ll be able to ask it the status of Sundays conference championship match-ups, and offer up its own predictions if you ask it something like, "Alexa, who will win the Super Bowl?" For movies, you can use phrases like, "Alexa, when is Spotlight playing on Friday?" for schedules or, "Alexa, tell me about The Revenant," for a film description.

Amazon has been on quite the roll with Echo updates of late, adding the ability to play Jeopardy with Alexa earlier this month and then pushing out a Kindle ebook dictation feature the week after. The companys long-term play for Alexa and the Echo is turn the pair into a low-key voice-powered smart home hub that easily connects with other companies appliances. Of course, its most useful function — to Amazon at least — is helping you order more stuff from Amazon.com.

                                          source :- http://www.theverge.com/
Read More..

Android Audio Demo AudioTrack AudioRecord Echo Sample

Simple echo application for how to use android AudioTrack and AudioRecord classes
Download Source
Step 1
    Create MainActivity class for audio record and play

package com.javaorigin.audio;

import android.media.AudioFormat;
import android.media.AudioManager;
import android.media.AudioRecord;
import android.media.AudioTrack;
import android.media.MediaRecorder;
import android.os.Bundle;
import android.app.Activity;
import android.content.Context;
import android.view.Menu;
import android.view.View;
import android.widget.Button;

public class MainActivity extends Activity {
AudioManager am = null;
AudioRecord record =null;
AudioTrack track =null;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setVolumeControlStream(AudioManager.MODE_IN_COMMUNICATION);
init();
(new Thread() {
@Override
public void run() {
recordAndPlay();
}
}).start();
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
}

private void init() {
int min = AudioRecord.getMinBufferSize(8000, AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT);
record = new AudioRecord(MediaRecorder.AudioSource.VOICE_COMMUNICATION, 8000, AudioFormat.CHANNEL_IN_MONO,
AudioFormat.ENCODING_PCM_16BIT, min);

int maxJitter = AudioTrack.getMinBufferSize(8000, AudioFormat.CHANNEL_OUT_MONO, AudioFormat.ENCODING_PCM_16BIT);
track = new AudioTrack(AudioManager.MODE_IN_COMMUNICATION, 8000, AudioFormat.CHANNEL_OUT_MONO,
AudioFormat.ENCODING_PCM_16BIT, maxJitter, AudioTrack.MODE_STREAM);
}

private void recordAndPlay() {
short[] lin = new short[1024];
int num = 0;
am = (AudioManager) this.getSystemService(Context.AUDIO_SERVICE);
am.setMode(AudioManager.MODE_IN_COMMUNICATION);
record.startRecording();
track.play();
while (true) {
num = record.read(lin, 0, 1024);
track.write(lin, 0, num);
}
}

boolean isSpeaker = false;

public void modeChange(View view) {
Button modeBtn=(Button) findViewById(R.id.modeBtn);
if (isSpeaker == true) {
am.setSpeakerphoneOn(false);
isSpeaker = false;
modeBtn.setText("Call Mode");
} else {
am.setSpeakerphoneOn(true);
isSpeaker = true;
modeBtn.setText("Speaker Mode");
}
}

boolean isPlaying=true;
public void play(View view){
Button playBtn=(Button) findViewById(R.id.playBtn);
if(isPlaying){
record.stop();
track.pause();
isPlaying=false;
playBtn.setText("Play");
}else{
record.startRecording();
track.play();
isPlaying=true;
playBtn.setText("Pause");
}
}

}
Step 2
        Add Button for Play/Pause and Call mode/ Speaker mode
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >



<Button
android:id="@+id/modeBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView1"
android:layout_below="@+id/textView1"
android:layout_marginTop="24dp"
android:text="Call Mode"
android:onClick="modeChange"/>

<Button
android:id="@+id/playBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/modeBtn"
android:layout_alignBottom="@+id/modeBtn"
android:layout_marginLeft="30dp"
android:layout_toRightOf="@+id/modeBtn"
android:onClick="play"
android:text="Pause" />

</RelativeLayout>

Step 3
    Add audio related permission to Android.xml
    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"></uses-permission>
    <uses-permission android:name="android.permission.RECORD_AUDIO"></uses-permission>
Read More..

Blog Archive

Powered by Blogger.