static CommandLineInterface()
        {
            string apiKey    = Environment.GetEnvironmentVariable("VOICEKIT_API_KEY");
            string secretKey = Environment.GetEnvironmentVariable("VOICEKIT_SECRET_KEY");

            if (string.IsNullOrEmpty(apiKey))
            {
                throw new ArgumentException("VOICEKIT_API_KEY does not exist in the enviroment variable");
            }
            if (string.IsNullOrEmpty(secretKey))
            {
                throw new ArgumentException("VOICEKIT_SECRET_KEY does not exist in the enviroment variable");
            }

            _client = new VoiceKitClient(apiKey, secretKey);
        }
Beispiel #2
0
        static void gRPc_connect(string path)
        {
            // создаем канал для обмена сообщениями с сервером
            // параметр - адрес сервера gRPC



            // создаем клиента

            //  var client = new Greeter.GreeterClient(channel);
            // var mp3 = new MP3File(@"C:\Users\IlinKS\source\repos\JWT_gRPC_console\JWT_gRPC_console\2020.10.12_21.15.41_79214430425_incoming_mixed_79098420960.mp3","testik");
            // string path = @"C:\Users\IlinKS\source\repos\JWT_gRPC_console\JWT_gRPC_console\2020.10.12_21.15.41_79214430425_incoming_mixed_79098420960.mp3";
            // string path = @"c:\Users\ilinks\source\repos\JWT_gRPC_console\JWT_gRPC_console\6650322009_89136872782_2020-01-24_08_24_12.wav";

            var audio = TagLib.File.Create(path);

            var vkc = new VoiceKitClient("bnZ6cWRvcWJncWNud2dqcGxtZ21ndXVvZXdjaWpueHk=m.rogencovfilbert", "YXlzdXBvaWhrdmZzZmtvYXZtb3plaHZqeGlrcGZ1d2c=");

            // первый запрос
            StreamingRecognitionConfig streaming_config = new StreamingRecognitionConfig();

            streaming_config.Config = new RecognitionConfig();

            streaming_config.Config.SampleRateHertz = (uint)audio.Properties.AudioSampleRate;
            streaming_config.Config.NumChannels     = (uint)audio.Properties.AudioChannels;

            audio.Dispose();

//           using FileStream fstream =  File.Open(path, FileMode.Open);

            switch (Path.GetExtension(path))
            {
            case ".mp3":
                streaming_config.Config.Encoding = AudioEncoding.MpegAudio;
                vkc.StreamingRecognize(streaming_config, File.Open(path, FileMode.Open)).GetAwaiter().GetResult();
                break;

            case ".wav":
                streaming_config.Config.Encoding = AudioEncoding.Linear16;
                vkc.StreamingRecognizeWAV(streaming_config, WavToPcmConvert(path)).GetAwaiter().GetResult();
                break;
            }



            return;
        }