Simple interface for speech using microphone and Google Cloud API.
-
Save Google Cloud API service account credentials file to local disk.
-
Set the credentials file path to GOOGLE_APPLICATION_CREDENTIALS environment variable
-
Execute the following code:
println("Opening speech recognition...") val speaker = Speaker() val listener = Listener("en-US", 0.0005, { text -> println("Recognised speech: $text") speaker.say(text) if (text.equals("exit")) { exit = true } }) println("Opened speech recognition.") println("Say exit to quit program.") while(!exit) { Thread.sleep(100) } println("Closing speech recognition...") listener.close() println("Closed speech recognition.") println("Exit.")