Esempio n. 1
0
        public static GoogleSpeechSession CreateSession(string socketId, GoogleSessionConfig config, Action <string, string[]> processTranscripts)
        {
            _log.Debug("Creating new GOOGLE SPEECH SESSION");
            var session = new GoogleSpeechSession(socketId, config, processTranscripts);

            _sessions.TryAdd(socketId, session);
            return(session);
        }
        public GoogleSpeechSession(string socketId, GoogleSessionConfig config, Action <string, string[]> processTranscripts)
        {
            try
            {
                _log.Debug($"Creating google api session: {socketId} - {config}");
                var speech = SpeechClient.Create();
                _streamingCall     = speech.StreamingRecognize();
                SockedId           = socketId;
                Config             = config;
                ProcessTranscripts = processTranscripts;

                _audioFileName   = $"{DateTime.Now:yyyyMMddHHmmss}.wav";
                _audioFileStream = File.OpenWrite(Path.Combine($@"c:\temp", _audioFileName));
            }
            catch (Exception e)
            {
                _log.Error(e);
            }
        }