How would I write a voice object for the following code?

26 views Asked by At

So far, I am planning to simulate a CAD system on a city bus. I am in the beginning phases of it which is just to basically create the voice. I at this point have no experience with creating voice objects. My question is, how would I create a voice object to read off the following messages?

import java.util.*;
import java.io.*;

public class message {
  public static void main(String[] args) {
    Scanner input = new Scanner(System.in);
    String message = "";
    System.out.print("Please enter a number between 1 through 5");
    int num = input.nextInt();
    if (num == 1)
      message = "Please do not use profanity on the bus";
    if (num == 2)
      message = "Help us get you there faster. If able, please use the rear exit";
    if (num == 3)
      message = "Please remember, seats are not for feet.";
    if (num == 4)
      message = "Thank you for using headphones, also please keep your cell phone conversations quiet.";
    if (num == 5)
      message = "Please do not speak with the driver while the bus is moving.";
    System.out.println(message);
  }
}

So far, I set this up to print it on the LED display, I am trying to figure out still how I would incorporate the voice into this system for it to say the messages whenever I select one. Any help would be appreciated.

0

There are 0 answers