public Recorder(PronunciationAssessment pronunciationAssessment, int sampleRate = 16000) { this.pronunciationAssessment = pronunciationAssessment; waveIn.WaveFormat = new WaveFormat(sampleRate, 1); waveIn.DataAvailable += WaveIn_DataAvailable; waveIn.RecordingStopped += WaveIn_Stopped; }
static void Main(string[] args) { var subscriptionKey = "{SubscriptionKey}"; // replace this with your subscription key var region = "{Region}"; // replace this with the region corresponding to your subscription key, e.g. westus, eastasia var referenceText = "Welcome to use Microsoft Cognitive Services pronunciation assessment API!"; var pronAssessment = new PronunciationAssessment(CultureInfo.GetCultureInfo("en-US"), region, subscriptionKey); var recorder = new Recorder(pronAssessment); Console.WriteLine("Please press any key to start recording, and then read along below text after recording started:"); Console.WriteLine("\r\n " + referenceText + "\r\n"); Console.ReadKey(true); recorder.Start(referenceText); Console.WriteLine("Recording started. Please read along above text. And after you finish reading it, press any key to stop recording."); Console.ReadKey(true); Console.WriteLine("Recording stopped."); Console.WriteLine("Here is the assessment result on your pronunciation:"); recorder.Stop(); Console.ReadKey(true); }