Browse Source

Merge branch 'master' of yannicpunktdee.de:yannic/YoshiBot

greetings_byebyes
Paul Glaß 4 years ago
parent
commit
320f0cb1cb
2 changed files with 26 additions and 12 deletions
  1. +11
    -3
      app/src/main/java/de/yannicpunktdee/yoshibot/command/commands/PlayCommand.java
  2. +15
    -9
      app/src/main/java/de/yannicpunktdee/yoshibot/command/commands/SayCommand.java

+ 11
- 3
app/src/main/java/de/yannicpunktdee/yoshibot/command/commands/PlayCommand.java View File

@ -19,6 +19,16 @@ public class PlayCommand extends YoshiCommand {
super(context);
}
public static boolean play(String fileName, VoiceChannel vc){
YoshiBot yoshiBot = YoshiBot.getInstance();
AudioController ac = yoshiBot.audioControllerManager.getController(vc.getGuild().getIdLong());
vc.getGuild().getAudioManager().openAudioConnection(vc);
yoshiBot.audioPlayerManager.loadItem(fileName, new AudioLoadResultHandlerImpl(ac));
return true;
}
@Override
public boolean execute() {
if(!super.execute()) return false;
@ -38,9 +48,7 @@ public class PlayCommand extends YoshiCommand {
return false;
}
AudioController ac = yoshiBot.audioControllerManager.getController(vc.getGuild().getIdLong());
vc.getGuild().getAudioManager().openAudioConnection(vc);
yoshiBot.audioPlayerManager.loadItem(fileName, new AudioLoadResultHandlerImpl(ac));
play(fileName, vc);
return true;
}


+ 15
- 9
app/src/main/java/de/yannicpunktdee/yoshibot/command/commands/SayCommand.java View File

@ -28,26 +28,23 @@ public class SayCommand extends YoshiCommand {
super(context);
}
@Override
public boolean execute() {
if(!super.execute()) return false;
public static String buildTTSAudio(String text){
String path = Resources.buildTempAudioFilePath(UUID.randomUUID().toString());
File test = new File(System.getProperty("java.io.tmpdir") + "/yoshibot");
if (!test.exists()) {
if (!test.mkdir()) {
Logger.log("Tempordner konnte nicht erstellt werden!", Logger.Type.ERROR);
return false;
return null;
}
}
try {
ProcessBuilder pb = new ProcessBuilder(
"python3",
Resources.getTts_path(),
"--text",
context.getArgument("text"),
text,
"--lang",
"de",
"--out",
@ -70,9 +67,18 @@ public class SayCommand extends YoshiCommand {
}
} catch (IOException | InterruptedException e) {
e.printStackTrace();
return false;
return null;
}
return path;
}
@Override
public boolean execute() {
if(!super.execute()) return false;
String path = buildTTSAudio(context.getArgument("text"));
List<VoiceChannel> channels = YoshiBot.getInstance().jda.getVoiceChannelsByName(context.getArgument("channel"), true);
if(!(channels.size() > 0)) {
context.getEvent().getTextChannel().sendMessage("Der Kanalname konnte nicht gefunden werden.").queue();


Loading…
Cancel
Save