Commit 0dee671b authored by Martin LOISEAU's avatar Martin LOISEAU 🎄
Browse files

Add TTS demo

parent 98f199dd
......@@ -9,19 +9,31 @@ import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.os.Environment;
import android.speech.tts.TextToSpeech;
import android.util.Log;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;
import java.util.Locale;
public class MainActivity extends AppCompatActivity {
MediaPlayer mp;
TextToSpeech tts;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
tts = new TextToSpeech(this, new TextToSpeech.OnInitListener() {
@Override
public void onInit(int status) {
tts.setLanguage(Locale.FRENCH);
}
});
FloatingActionButton photo = findViewById(R.id.photo);
// Should open camera to take a picture of a QR code
......@@ -40,6 +52,7 @@ public class MainActivity extends AppCompatActivity {
public void onClick(View view) {
Snackbar.make(view, "Should read some text out loud using speech synthesis", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
PlayDemoTTS();
}
});
......@@ -94,4 +107,10 @@ public class MainActivity extends AppCompatActivity {
mp.start();
return true;
}
public boolean PlayDemoTTS() {
tts.speak("Bonjour et bienvenue dans QR Quest", TextToSpeech.QUEUE_ADD, null);
return true;
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment