|
@@ -5,28 +5,27 @@ using TencentCloud.Asr.V20190614;
|
|
|
using TencentCloud.Asr.V20190614.Models;
|
|
|
using TencentCloud.Common;
|
|
|
using TencentCloud.Common.Profile;
|
|
|
+using WingServerCommon.Config;
|
|
|
+using WingServerCommon.Config.Parameters;
|
|
|
using WingServerCommon.Log;
|
|
|
|
|
|
namespace WingASRService.Tencent
|
|
|
{
|
|
|
public class ASRApi
|
|
|
{
|
|
|
- private ASRApi(){}
|
|
|
-
|
|
|
+ private ASRApi() { }
|
|
|
+
|
|
|
public static (string message, bool isSuccess) CallASRApi(string url, string fileType)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
// 实例化一个认证对象,入参需要传入腾讯云账户secretId,secretKey,此处还需注意密钥对的保密
|
|
|
// 密钥可前往https://console.cloud.tencent.com/cam/capi网站进行获取
|
|
|
- Credential cred = new Credential {
|
|
|
- SecretId = "AKIDgDUVFbjbDahYAXeV6RXNxHK8gy0mJabN",
|
|
|
- SecretKey = "XprdARRBgusa3GEwObYFgrmRq0uYv3vY"
|
|
|
+ Credential cred = new Credential
|
|
|
+ {
|
|
|
+ SecretId = ConfigurationManager.GetParammeter<StringParameter>("WeChat", "SecretId").Value,
|
|
|
+ SecretKey = ConfigurationManager.GetParammeter<StringParameter>("WeChat", "SecretKey").Value
|
|
|
};
|
|
|
- // Credential cred = new Credential {
|
|
|
- // SecretId = "AKIDMSIsADUUpvJGwJOKvsb5IDrGtGNBRzzi",
|
|
|
- // SecretKey = "4sQhdJBl5HI7f3oLbZIlwqXOyILyLWP0"
|
|
|
- // };
|
|
|
// 实例化一个client选项,可选的,没有特殊需求可以跳过
|
|
|
ClientProfile clientProfile = new ClientProfile();
|
|
|
// 实例化一个http选项,可选的,没有特殊需求可以跳过
|
|
@@ -52,11 +51,11 @@ namespace WingASRService.Tencent
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
- var regMatch = Regex.Match(e.Message,@".*code:([.\w]+)[\s]+.*");
|
|
|
- if(regMatch.Groups.Count>1)
|
|
|
+ var regMatch = Regex.Match(e.Message, @".*code:([.\w]+)[\s]+.*");
|
|
|
+ if (regMatch.Groups.Count > 1)
|
|
|
{
|
|
|
var errorCode = regMatch.Groups[1].Value;
|
|
|
- if(!string.IsNullOrWhiteSpace(errorCode) && ASRErrorCode.ErrorsDictionary.Keys.Contains(errorCode))
|
|
|
+ if (!string.IsNullOrWhiteSpace(errorCode) && ASRErrorCode.ErrorsDictionary.Keys.Contains(errorCode))
|
|
|
{
|
|
|
var errorMessage = ASRErrorCode.ErrorsDictionary[errorCode];
|
|
|
Logger.WriteLineError($"ASRApi.CallASRApi url:{url} code:{errorCode} message:{errorMessage}");
|
|
@@ -64,7 +63,7 @@ namespace WingASRService.Tencent
|
|
|
}
|
|
|
}
|
|
|
Logger.WriteLineError($"ASRApi.CallASRApi url:{url} error {e}");
|
|
|
- return (message: "Unknow error", isSuccess: false);;
|
|
|
+ return (message: "Unknow error", isSuccess: false); ;
|
|
|
}
|
|
|
}
|
|
|
}
|