public void SynthesizeSpeech()
        {
            Mock <TextToSpeech.TextToSpeechClient> mockGrpcClient = new Mock <TextToSpeech.TextToSpeechClient>(MockBehavior.Strict);
            SynthesizeSpeechRequest expectedRequest = new SynthesizeSpeechRequest
            {
                Input       = new SynthesisInput(),
                Voice       = new VoiceSelectionParams(),
                AudioConfig = new AudioConfig(),
            };
            SynthesizeSpeechResponse expectedResponse = new SynthesizeSpeechResponse
            {
                AudioContent = ByteString.CopyFromUtf8("16"),
            };

            mockGrpcClient.Setup(x => x.SynthesizeSpeech(expectedRequest, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            TextToSpeechClient       client      = new TextToSpeechClientImpl(mockGrpcClient.Object, null);
            SynthesisInput           input       = new SynthesisInput();
            VoiceSelectionParams     voice       = new VoiceSelectionParams();
            AudioConfig              audioConfig = new AudioConfig();
            SynthesizeSpeechResponse response    = client.SynthesizeSpeech(input, voice, audioConfig);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
示例#2
0
        public void SynthesizeSpeechRequestObject()
        {
            moq::Mock <TextToSpeech.TextToSpeechClient> mockGrpcClient = new moq::Mock <TextToSpeech.TextToSpeechClient>(moq::MockBehavior.Strict);
            SynthesizeSpeechRequest request = new SynthesizeSpeechRequest
            {
                Input              = new SynthesisInput(),
                Voice              = new VoiceSelectionParams(),
                AudioConfig        = new AudioConfig(),
                EnableTimePointing =
                {
                    SynthesizeSpeechRequest.Types.TimepointType.Unspecified,
                },
            };
            SynthesizeSpeechResponse expectedResponse = new SynthesizeSpeechResponse
            {
                AudioContent = proto::ByteString.CopyFromUtf8("audio_content20992f23"),
                Timepoints   = { new Timepoint(), },
                AudioConfig  = new AudioConfig(),
            };

            mockGrpcClient.Setup(x => x.SynthesizeSpeech(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            TextToSpeechClient       client   = new TextToSpeechClientImpl(mockGrpcClient.Object, null);
            SynthesizeSpeechResponse response = client.SynthesizeSpeech(request);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }