Commit 2a6fd051 authored by helinlin's avatar helinlin

提取阿里云语音识别appKey等参数

parent 38065ee0
package com.yeejoin.amos.boot.module.jcs.biz.audioToText.entity;
import lombok.Data;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
@Data
@Component
@ConfigurationProperties(prefix = "speech-config")
public class SpeechConfig implements InitializingBean {
public String accessKeyId;
public String accessKeySecret;
public String appKey;
@Override
public void afterPropertiesSet() throws Exception {
com.yeejoin.amos.speech.SpeechConfig.AccessKeyId = accessKeyId;
com.yeejoin.amos.speech.SpeechConfig.AccessKeySecret = accessKeySecret;
com.yeejoin.amos.speech.SpeechConfig.AppKey = appKey;
}
}
...@@ -113,4 +113,9 @@ auth-key-fire-fighters=fire_fighters_info ...@@ -113,4 +113,9 @@ auth-key-fire-fighters=fire_fighters_info
mybatis.interceptor.enabled = false mybatis.interceptor.enabled = false
## 消防救援保障部ID ## 消防救援保障部ID
fire-rescue=1432549862557130753 fire-rescue=1432549862557130753
\ No newline at end of file
#???????????
speech-config.access-key-id=LTAI5t7mGN6dYoCwMdKiLTgt
speech-config.access-key-secret=0LYdEnvKzQxBg0lpIahDp5rzB2r4Dp
speech-config.app-key=EG5fJBBIqkNMj6bM
\ No newline at end of file
...@@ -85,7 +85,7 @@ class AppNslClientToken { ...@@ -85,7 +85,7 @@ class AppNslClientToken {
* @return token 访问token * @return token 访问token
*/ */
private static AccessToken getAccessToken() { private static AccessToken getAccessToken() {
AccessToken accessToken = new AccessToken(SpeechConfig.AccessKeId, SpeechConfig.AccessKeySecret); AccessToken accessToken = new AccessToken(SpeechConfig.AccessKeyId, SpeechConfig.AccessKeySecret);
try { try {
accessToken.apply(); accessToken.apply();
logger.warn("获取到最新的token: " + accessToken.getToken() + ", 过期时间: " + accessToken.getExpireTime() + "(" + accessToken.getExpireTime() / (1000 * 60 * 60 * 24) + "天)"); logger.warn("获取到最新的token: " + accessToken.getToken() + ", 过期时间: " + accessToken.getExpireTime() + "(" + accessToken.getExpireTime() / (1000 * 60 * 60 * 24) + "天)");
......
...@@ -23,8 +23,8 @@ public class SpeechConfig { ...@@ -23,8 +23,8 @@ public class SpeechConfig {
/** /**
* 测试信息,可在阿里云上配置 * 测试信息,可在阿里云上配置
*/ */
public static final String AccessKeId = "LTAI5t7mGN6dYoCwMdKiLTgt"; public static String AccessKeyId = "";
public static final String AccessKeySecret = "0LYdEnvKzQxBg0lpIahDp5rzB2r4Dp"; public static String AccessKeySecret = "";
public static final String AppKey = "EG5fJBBIqkNMj6bM"; public static String AppKey = "";
} }
...@@ -69,7 +69,7 @@ public class SpeechRecognizer { ...@@ -69,7 +69,7 @@ public class SpeechRecognizer {
e.printStackTrace(); e.printStackTrace();
} }
// 创建DefaultAcsClient实例并初始化 // 创建DefaultAcsClient实例并初始化
DefaultProfile profile = DefaultProfile.getProfile(REGIONID, SpeechConfig.AccessKeId, SpeechConfig.AccessKeySecret); DefaultProfile profile = DefaultProfile.getProfile(REGIONID, SpeechConfig.AccessKeyId, SpeechConfig.AccessKeySecret);
this.client = new DefaultAcsClient(profile); this.client = new DefaultAcsClient(profile);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment