新增讯飞语音SDK
新增机器人:开灯、开空调、语音等指令 优化每次启动程序都会重新扫描音乐库 新增晚上8点新番提醒
This commit is contained in:
parent
a42714054f
commit
5aca836fef
BIN
libmsc32.so
Normal file
BIN
libmsc32.so
Normal file
Binary file not shown.
BIN
libmsc64.so
Normal file
BIN
libmsc64.so
Normal file
Binary file not shown.
BIN
libs/Msc.jar
Normal file
BIN
libs/Msc.jar
Normal file
Binary file not shown.
BIN
libs/json-jena-1.0.jar
Normal file
BIN
libs/json-jena-1.0.jar
Normal file
Binary file not shown.
14
pom.xml
14
pom.xml
@ -126,6 +126,20 @@
|
|||||||
<artifactId>ffmpeg</artifactId>
|
<artifactId>ffmpeg</artifactId>
|
||||||
<version>0.6.2</version>
|
<version>0.6.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.iflytek</groupId>
|
||||||
|
<artifactId>msc</artifactId>
|
||||||
|
<version>4.1</version>
|
||||||
|
<scope>system</scope>
|
||||||
|
<systemPath>${project.basedir}/libs/Msc.jar</systemPath>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.iflytek</groupId>
|
||||||
|
<artifactId>json</artifactId>
|
||||||
|
<version>4.1</version>
|
||||||
|
<scope>system</scope>
|
||||||
|
<systemPath>${project.basedir}/libs/json-jena-1.0.jar</systemPath>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
@ -9,7 +9,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
public class ToolsApplication {
|
public class ToolsApplication {
|
||||||
public static final String version="1.0.16.12";
|
public static final String version="1.0.16.13";
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
System.out.println("当前版本号:"+version);
|
System.out.println("当前版本号:"+version);
|
||||||
|
9
src/main/java/com/yutou/tools/other/QQAudio.java
Normal file
9
src/main/java/com/yutou/tools/other/QQAudio.java
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
package com.yutou.tools.other;
|
||||||
|
|
||||||
|
import com.yutou.tools.utils.AudioTools;
|
||||||
|
|
||||||
|
public class QQAudio {
|
||||||
|
public static void playText(String text){
|
||||||
|
AudioTools.playText(text);
|
||||||
|
}
|
||||||
|
}
|
@ -20,7 +20,7 @@ public class ApplicationInit implements ApplicationRunner {
|
|||||||
MusicTools musicTools;
|
MusicTools musicTools;
|
||||||
@Override
|
@Override
|
||||||
public void run(ApplicationArguments args) throws Exception {
|
public void run(ApplicationArguments args) throws Exception {
|
||||||
musicTools.init();//初始化音乐库
|
AudioTools.init();
|
||||||
new Timer().schedule(new TimerTask() {
|
new Timer().schedule(new TimerTask() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -30,6 +30,7 @@ public class ApplicationInit implements ApplicationRunner {
|
|||||||
musicTools.scanMusic();
|
musicTools.scanMusic();
|
||||||
break;
|
break;
|
||||||
case "08:00":
|
case "08:00":
|
||||||
|
case "20:00":
|
||||||
QQBotManager.getInstance().reportToDayBangumi();
|
QQBotManager.getInstance().reportToDayBangumi();
|
||||||
break;
|
break;
|
||||||
case "23:59":
|
case "23:59":
|
||||||
|
63
src/main/java/com/yutou/tools/utils/AudioTools.java
Normal file
63
src/main/java/com/yutou/tools/utils/AudioTools.java
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
package com.yutou.tools.utils;
|
||||||
|
|
||||||
|
import com.iflytek.cloud.speech.*;
|
||||||
|
|
||||||
|
public class AudioTools {
|
||||||
|
private static boolean init = false;
|
||||||
|
|
||||||
|
synchronized static void init() {
|
||||||
|
if (init) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
SpeechUtility.createUtility(SpeechConstant.APPID + "=601f7f7d");
|
||||||
|
init = true;
|
||||||
|
System.out.println("讯飞语音已初始化");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void playText(String text) {
|
||||||
|
SpeechSynthesizer mss = SpeechSynthesizer.createSynthesizer();
|
||||||
|
mss.startSpeaking(text, new SynthesizerListener() {
|
||||||
|
@Override
|
||||||
|
public void onBufferProgress(int progress, int beginPos, int endPos,
|
||||||
|
String info) {
|
||||||
|
if (progress == 100) {
|
||||||
|
mss.destroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSpeakBegin() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSpeakProgress(int i, int i1, int i2) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSpeakPaused() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSpeakResumed() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCompleted(SpeechError speechError) {
|
||||||
|
System.out.println(speechError.getErrorDesc() + " code " + speechError.getErrorCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEvent(int i, int i1, int i2, int i3, Object o, Object o1) {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
init();
|
||||||
|
playText("小爱同学,开灯");
|
||||||
|
}
|
||||||
|
}
|
@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
|
|||||||
import com.yutou.tools.ToolsApplication;
|
import com.yutou.tools.ToolsApplication;
|
||||||
import com.yutou.tools.bangumi.BangumiTools;
|
import com.yutou.tools.bangumi.BangumiTools;
|
||||||
import com.yutou.tools.interfaces.DownloadInterface;
|
import com.yutou.tools.interfaces.DownloadInterface;
|
||||||
|
import com.yutou.tools.other.QQAudio;
|
||||||
import com.yutou.tools.other.QQSetu;
|
import com.yutou.tools.other.QQSetu;
|
||||||
import net.mamoe.mirai.Bot;
|
import net.mamoe.mirai.Bot;
|
||||||
import net.mamoe.mirai.BotFactory;
|
import net.mamoe.mirai.BotFactory;
|
||||||
@ -19,6 +20,7 @@ import java.io.IOException;
|
|||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
@ -37,6 +39,9 @@ public class QQBotManager {
|
|||||||
private final static String QQ_BANGUMI_TODAY = "!今日动画";
|
private final static String QQ_BANGUMI_TODAY = "!今日动画";
|
||||||
private final static String QQ_BANGUMI_LIST = "!新番";
|
private final static String QQ_BANGUMI_LIST = "!新番";
|
||||||
private final static String QQ_BANGUMI_SUB = "!查动画";
|
private final static String QQ_BANGUMI_SUB = "!查动画";
|
||||||
|
private final static String QQ_AUDIO = "!语音";
|
||||||
|
private final static String QQ_AUDIO_OPEN_LAMP = "!开灯";
|
||||||
|
private final static String QQ_AUDIO_OPEN_AIR = "!开空调";
|
||||||
}
|
}
|
||||||
|
|
||||||
private static QQBotManager botManager = null;
|
private static QQBotManager botManager = null;
|
||||||
@ -46,7 +51,6 @@ public class QQBotManager {
|
|||||||
private static boolean isInit = false;
|
private static boolean isInit = false;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private QQBotManager() {
|
private QQBotManager() {
|
||||||
Object isRun = ConfigTools.load(ConfigTools.CONFIG, "qq_bot");
|
Object isRun = ConfigTools.load(ConfigTools.CONFIG, "qq_bot");
|
||||||
if (isRun != null && (boolean) isRun) {
|
if (isRun != null && (boolean) isRun) {
|
||||||
@ -147,6 +151,7 @@ public class QQBotManager {
|
|||||||
}
|
}
|
||||||
return getNotLoginQQ();
|
return getNotLoginQQ();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendMessage(Long group, MessageChainBuilder builder) {
|
public void sendMessage(Long group, MessageChainBuilder builder) {
|
||||||
if (bot != null) {
|
if (bot != null) {
|
||||||
Objects.requireNonNull(bot.getGroup(group)).sendMessage(builder.asMessageChain());
|
Objects.requireNonNull(bot.getGroup(group)).sendMessage(builder.asMessageChain());
|
||||||
@ -221,6 +226,15 @@ public class QQBotManager {
|
|||||||
switch (msg) {
|
switch (msg) {
|
||||||
case QQCommands.QQ_OPEN_PC:
|
case QQCommands.QQ_OPEN_PC:
|
||||||
RedisTools.Consumer.system("openPC", null);
|
RedisTools.Consumer.system("openPC", null);
|
||||||
|
String time = new SimpleDateFormat("HH").format(new Date());
|
||||||
|
if (Integer.parseInt(time) < 18) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case QQCommands.QQ_AUDIO_OPEN_LAMP:
|
||||||
|
QQAudio.playText("小爱同学,开灯");
|
||||||
|
break;
|
||||||
|
case QQCommands.QQ_AUDIO_OPEN_AIR:
|
||||||
|
QQAudio.playText("小爱同学,开空调");
|
||||||
break;
|
break;
|
||||||
case QQCommands.QQ_UPDATE_IP:
|
case QQCommands.QQ_UPDATE_IP:
|
||||||
RedisTools.Consumer.system("updateIP", null);
|
RedisTools.Consumer.system("updateIP", null);
|
||||||
@ -238,6 +252,7 @@ public class QQBotManager {
|
|||||||
getInstance().sendMessage("获取中...");
|
getInstance().sendMessage("获取中...");
|
||||||
getInstance().sendMessage(BangumiTools.reportBangumiList());
|
getInstance().sendMessage(BangumiTools.reportBangumiList());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case QQCommands.QQ_HELP:
|
case QQCommands.QQ_HELP:
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
for (Field field : QQCommands.class.getDeclaredFields()) {
|
for (Field field : QQCommands.class.getDeclaredFields()) {
|
||||||
@ -270,6 +285,8 @@ public class QQBotManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
sendImagesMsg(imgs, info);
|
sendImagesMsg(imgs, info);
|
||||||
|
} else if (msg.startsWith(QQCommands.QQ_AUDIO)) {
|
||||||
|
QQAudio.playText(msg.replace(QQCommands.QQ_AUDIO, ""));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user