Hi
I’ve got this code, it’s AT&T speech rec. It works on unity but not in android, any ideas why?? It builds for android fine and works, it playbacks the sound but then the label doesn’t get input from AT&T API i think. Maybe something wrong in android with the file saving???
// Label for speech
SpeechLbl = GameObject.Find ("SpeechLabel").GetComponent<UILabel> ();
// Start microphone, wait 5 seconds then end recording.
GetComponent<AudioSource>().clip = Microphone.Start (null,false,5,8000);
yield return new WaitForSeconds(5);
Microphone.End(null);
// Playback what we've got.
GetComponent<AudioSource>().Play();
// Generate audio data clip.
float[] clipData = new float[GetComponent<AudioSource>().clip.samples * GetComponent<AudioSource>().clip.channels];
GetComponent<AudioSource>().clip.GetData(clipData,0);
WaveGen.WaveFormatChunk format = new WaveGen().MakeFormat(GetComponent<AudioSource>().clip);
// Create a file in local app path.
string filename = "recordedSpeech.wav";
filePath = Application.persistentDataPath + "/" + filename;
FileStream stream = File.OpenWrite(filePath);
new WaveGen().Write (clipData,format,stream);
stream.Close();
// Check response from AT&T API and save in speech label.
SpeechResponse response = requestFactory.SpeechToText (filePath);
string transcribedText = response.Recognition.NBest[0].ResultText;
SpeechLbl.text = transcribedText;