Giter Club home page Giter Club logo

text2speechdemo-rybackpo's Introduction

Text-to-Speech App (converts text into Speech)

text2speechdemo-rybackpo created by Classroom for GitHub

This assignment illustrates the conversion of text into speech in Android platform. It also introduces a ListView widget.

Problem:

Design and implement an Android app that takes a text file of ESL Telephone Alphabet phrases as input, then, outputs the texts in a ListView in which when clicked outputs speech.

text.txt

A is for Apple
B is for Boy
C is for Cat
D is for Dog
E is for East
F is for Five
G is for Goat
H is for House
I is for Ice cream
J is for July
K is for King
L is for Lemon
M is for Money
N is for Number
O is for Open
P is for People
Q is for Queen
R is for Red
S is for Summer
T is for Time
U is for Uniform
V is for Visa
W is for Woman
X is for X-ray
Y is for Yellow
Z is for Zebra

Sample Solution:

https://github.com/DeLaSalleUniversity-Manila/text2speechdemo-rybackpo

Keypoints:

Initialize the TextToSpeech Object:

private void initTextToSpeech(){
    txttospeech = new TextToSpeech(this, new TextToSpeech.OnInitListener() {
          @Override
          public void onInit(int status) {
              textloaded = true;
          }
    });
}

Load the Texts from text file:

private void getTextFromFile(){
    Texts = new ArrayList<String>();
    Scanner sc = new Scanner(getResources().openRawResource(R.raw.text));
    while(sc.hasNextLine()){
        String words = sc.nextLine();
        Texts.add(words);
    }
}

Set-up the ListView:

private void setupListView(){
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, Texts);
    ListView textList = (ListView) findViewById(R.id.textListView);
    textList.setAdapter(adapter);
    textList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                onClick(position);
        }
    });
}

Handle the clicks:

private void onClick(int index){
    String textline = Texts.get(index);
    if(textloaded){
        txttospeech.setSpeechRate(0.6f);
        txttospeech.speak(textline, TextToSpeech.QUEUE_FLUSH, null);
    }
}

Screenshots:

alt tag

alt tag

alt tag

text2speechdemo-rybackpo's People

Contributors

rybackpo avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.