|
|
@ -1,6 +1,7 @@ |
|
|
|
package de.yannicpunktdee.yoshibot.command; |
|
|
|
|
|
|
|
import de.yannicpunktdee.yoshibot.audio.AudioLoadResultHandlerImpl; |
|
|
|
import de.yannicpunktdee.yoshibot.command.commands.SayCommand; |
|
|
|
import de.yannicpunktdee.yoshibot.main.YoshiBot; |
|
|
|
import de.yannicpunktdee.yoshibot.utils.Logger; |
|
|
|
import de.yannicpunktdee.yoshibot.utils.Resources; |
|
|
@ -10,7 +11,10 @@ import net.dv8tion.jda.api.entities.MessageEmbed; |
|
|
|
import net.dv8tion.jda.api.entities.VoiceChannel; |
|
|
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent; |
|
|
|
|
|
|
|
import java.io.BufferedReader; |
|
|
|
import java.io.File; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.InputStreamReader; |
|
|
|
import java.util.List; |
|
|
|
import java.util.UUID; |
|
|
|
import java.util.concurrent.CompletableFuture; |
|
|
@ -30,6 +34,8 @@ public abstract class YoshiCommand { |
|
|
|
*/ |
|
|
|
protected YoshiCommandContext context; |
|
|
|
|
|
|
|
public static String resourceToDelete = null; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* Erzeugt ein neues Kommando, führt es aber noch nicht aus. Es wird ermittelt, ob die Argumentenkombination valide |
|
|
@ -41,6 +47,42 @@ public abstract class YoshiCommand { |
|
|
|
this.context = context; |
|
|
|
} |
|
|
|
|
|
|
|
public static String buildTTSAudio(String text) { |
|
|
|
String path = Resources.getPathToTempAudioFile(UUID.randomUUID().toString()); |
|
|
|
|
|
|
|
try { |
|
|
|
ProcessBuilder pb = new ProcessBuilder( |
|
|
|
"python3", |
|
|
|
Resources.getTtsPath(), |
|
|
|
"--text", |
|
|
|
text, |
|
|
|
"--lang", |
|
|
|
"de", |
|
|
|
"--out", |
|
|
|
path); |
|
|
|
|
|
|
|
Process p = pb.start(); |
|
|
|
BufferedReader errorReader = new BufferedReader(new InputStreamReader(p.getErrorStream())); |
|
|
|
StringBuilder builder = new StringBuilder(); |
|
|
|
String line; |
|
|
|
while ((line = errorReader.readLine()) != null) { |
|
|
|
builder.append(line).append("\n"); |
|
|
|
} |
|
|
|
if (builder.toString().length() > 0) { |
|
|
|
Logger.logError(builder.toString()); |
|
|
|
} |
|
|
|
if (resourceToDelete != null) |
|
|
|
synchronized (resourceToDelete) { |
|
|
|
resourceToDelete = path; |
|
|
|
} |
|
|
|
} catch (IOException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
return path; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Führt das Kommando aus. |
|
|
|
* |
|
|
|