IBM Watson API doesn't work in VSTO Excel workbook

0

I'm using IBM Watson TextToSpeech API, I got this snippet from the documentation, I try it in windows forms it worked flawlessly, but when I implement it in VSTO Excel Workbook it broke.

void TextToSpeech(string input)
{
    string tempPath = Path.GetTempFileName();
    IamAuthenticator authenticator = new IamAuthenticator(apikey: apikey);
    TextToSpeechService textToSpeech = new TextToSpeechService(authenticator);
    textToSpeech.SetServiceUrl(url);
    var result = textToSpeech.Synthesize(input, "audio/wav", "en-US_AllisonV3Voice");
    using (FileStream fs = File.Create(tempPath))
    {
        result.Result.WriteTo(fs);
        fs.Close();
        result.Result.Close();
    }
}

The error is in var result line.

Debug Output:

Exception thrown: 'System.Security.Authentication.AuthenticationException' in System.dll
Exception thrown: 'System.Security.Authentication.AuthenticationException' in System.dll
Exception thrown: 'System.Security.Authentication.AuthenticationException' in System.dll
Exception thrown: 'System.Security.Authentication.AuthenticationException' in System.dll
Exception thrown: 'System.Security.Authentication.AuthenticationException' in System.dll
Exception thrown: 'System.ObjectDisposedException' in System.dll
Exception thrown: 'System.Net.WebException' in System.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in mscorlib.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in mscorlib.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in mscorlib.dll
Exception thrown: 'System.AggregateException' in mscorlib.dll
Exception thrown: 'System.AggregateException' in IBM.Cloud.SDK.Core.dll
Exception thrown: 'System.AggregateException' in IBM.Watson.TextToSpeech.v1.dll
Exception thrown: 'System.Reflection.TargetInvocationException' in Microsoft.Office.Tools.Common.Implementation.dll
The thread 0x6148 has exited with code 0 (0x0).
The thread 0x5ea8 has exited with code 0 (0x0).
The thread 0x395c has exited with code 0 (0x0).
The thread 0x3f04 has exited with code 0 (0x0).
The thread 0x4e44 has exited with code 0 (0x0).
The thread 0x1198 has exited with code 0 (0x0).
The program '[9364] excel.exe: Program Trace' has exited with code 0 (0x0).
The program '[9364] excel.exe' has exited with code -1 (0xffffffff).
c#
excel
api
vsto
text-to-speech
asked on Stack Overflow Oct 15, 2020 by Aziz Ayoubi • edited Oct 15, 2020 by Aziz Ayoubi

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0