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