Example #1
0
        public Transcribed_Dto TranscribeAudioFile(TranscribeParameters transParams, string rawResponseFile = null)
        {
            LongRunningRecognizeResponse response = UploadAndTranscribeInCloud(transParams);

            // Save the raw response, if we were passed a file path.
            if (rawResponseFile != "")
            {
                string responseString = JsonConvert.SerializeObject(response, Formatting.Indented);
                File.WriteAllText(rawResponseFile, responseString);
            }

            Transcribed_Dto resp = TransformResponse.Simpify(response.Results);

            return(TransformResponse.FixSpeakerTags(resp));
        }
Example #2
0
        // Transcribe a local audio file. We can only use this with audios up to 1 minute long.
        public Transcribed_Dto TranscribeLocalFile(string fileName, string language)
        {
            //    // var speechClient = SpeechClient.Create();
            RecognitionAudio recogAudio = RecognitionAudio.FromFile(fileName);

            var response = speechClient.Recognize(new RecognitionConfig()
            {
                Encoding              = RecognitionConfig.Types.AudioEncoding.Flac,
                SampleRateHertz       = 48000,
                EnableWordTimeOffsets = true,
                LanguageCode          = language,
            }, recogAudio);

            Transcribed_Dto resp = TransformResponse.Simpify(response.Results);

            return(TransformResponse.FixSpeakerTags(resp));
        }