Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/311.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在已部署的WPF应用程序中使用google speech to text api密钥?_C#_Wpf_Google Cloud Speech - Fatal编程技术网

C# 如何在已部署的WPF应用程序中使用google speech to text api密钥?

C# 如何在已部署的WPF应用程序中使用google speech to text api密钥?,c#,wpf,google-cloud-speech,C#,Wpf,Google Cloud Speech,我创建了一个C#WPF应用程序,它使用谷歌语音到文本API。目前,在我的开发机器上,我在windows中添加了一个环境变量,它引用了google给我的JSON文件 我是否需要为部署我的应用程序的每台机器创建该环境变量,或者是否有办法将JSON密钥存储在服务器上并从那里引用它?可能会帮助您 这是从那里复制的代码: //某些API(如存储)在其Create()中接受凭据 //方法。 公共对象AuthExplicit(字符串projectId、字符串jsonPath) { //通过指定 //私钥文件。

我创建了一个C#WPF应用程序,它使用谷歌语音到文本API。目前,在我的开发机器上,我在windows中添加了一个环境变量,它引用了google给我的JSON文件

我是否需要为部署我的应用程序的每台机器创建该环境变量,或者是否有办法将JSON密钥存储在服务器上并从那里引用它?

可能会帮助您

这是从那里复制的代码:

//某些API(如存储)在其Create()中接受凭据
//方法。
公共对象AuthExplicit(字符串projectId、字符串jsonPath)
{
//通过指定
//私钥文件。
var-credential=GoogleCredential.FromFile(jsonPath);
var storage=StorageClient.Create(凭证);
//发出经过身份验证的API请求。
var bucket=storage.listbackes(projectId);
foreach(桶中的var桶)
{
Console.WriteLine(bucket.Name);
}
返回null;
}
//其他API(如语言)在其Create()中接受通道
//方法。
公共对象AuthExplicit(字符串projectId、字符串jsonPath)
{
LanguageServiceClientBuilder=新的LanguageServiceClientBuilder
{
CredentialsPath=jsonPath
};
LanguageServiceClient=builder.Build();
分析情绪(客户);
返回0;
}

通过环境变量将Google Speech配置为文本肯定有另一种选择。要回答您的问题,重要的是要知道谁将是您的WPF应用程序的用户。可以信任用户不滥用API密钥吗?因为你必须假设他们会找到它。谢谢你的回答。我必须使用SpeechClientBuilder来显式地传递凭证,这很有效。