Skip to content

Commit

Permalink
Flowery API changes (#213)
Browse files Browse the repository at this point in the history
* api changes

* fix stuff

---------

Co-authored-by: topi314 <git@topi.wtf>
  • Loading branch information
Ryan5453 and topi314 authored Aug 17, 2024
1 parent 4d63e88 commit bfd5b47
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 9 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ A collection of additional [Lavaplayer v2](/~https://github.com/sedmelluq/lavaplay
* [Apple Music](https://www.apple.com/apple-music/) playlists/albums/songs/artists/search results/[LavaSearch](/~https://github.com/topi314/LavaSearch)(Big thx to [ryan5453](/~https://github.com/ryan5453) for helping me)
* [Deezer](https://www.deezer.com) playlists/albums/songs/artists/search results/[LavaSearch](/~https://github.com/topi314/LavaSearch)/[LavaLyrics](/~https://github.com/topi314/LavaLyrics)(Big thx to [ryan5453](/~https://github.com/ryan5453) and [melike2d](/~https://github.com/melike2d) for helping me)
* [Yandex Music](https://music.yandex.ru) playlists/albums/songs/artists/podcasts/search results/[LavaLyrics](/~https://github.com/topi314/LavaLyrics)/[LavaSearch](/~https://github.com/topi314/LavaSearch)(Thx to [AgutinVBoy](/~https://github.com/agutinvboy) for implementing it)
* [Flowery TTS](https://flowery.pw/docs/flowery/synthesize-v-1-tts-get) (Thx to [bachtran02](/~https://github.com/bachtran02) for implementing it)
* [Flowery TTS](https://flowery.pw/docs) (Thx to [bachtran02](/~https://github.com/bachtran02) for implementing it)
* [YouTube](https://youtube.com) & [YouTubeMusic](https://music.youtube.com/) [LavaSearch](/~https://github.com/topi314/LavaSearch)/[LavaLyrics](/~https://github.com/topi314/LavaLyrics) (Thx to [DRSchlaubi](/~https://github.com/DRSchlaubi) for helping me)

> [!IMPORTANT]
Expand Down Expand Up @@ -274,7 +274,9 @@ Get list of all voices and languages supported [here](https://api.flowery.pw/v1/
```java
AudioPlayerManager playerManager = new DefaultAudioPlayerManager();

// create a new FloweryTTSSourceManager with a valid voice and register it
// create a new FloweryTTSSourceManager
playerManager.registerSourceManager(new FloweryTTSSourceManager());
// create a new FloweryTTSSourceManager with a default voice
playerManager.registerSourceManager(new FloweryTTSSourceManager("..."));
```

Expand Down Expand Up @@ -446,9 +448,8 @@ LavaSrc adds the following fields to tracks & playlists in Lavalink
* https://music.yandex.ru/artist/701626

### Flowery TTS
You can ready about all the available options [here](https://flowery.pw/docs/flowery/synthesize-v-1-tts-get),
a list of available voices is [here](https://api.flowery.pw/v1/tts/voices)
You can read about all the available options [here](https://flowery.pw/docs), a list of available voices is [here](https://api.flowery.pw/v1/tts/voices)

* `ftts://hello%20world`
* `ftts://hello%20world?audio_format=ogg_opus&translate=False&silence=1000&speed=1.0`
* `ftts://hello%20world?audio_format=ogg_opus&translate=False&silence=1000&speed=1.0&voice=09924826-684f-51e9-825b-cf85aed2b2cf`
---
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
import com.sedmelluq.discord.lavaplayer.source.AudioSourceManager;
import com.sedmelluq.discord.lavaplayer.tools.Units;
import com.sedmelluq.discord.lavaplayer.tools.io.PersistentHttpStream;
import com.sedmelluq.discord.lavaplayer.track.*;
import com.sedmelluq.discord.lavaplayer.track.AudioTrack;
import com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo;
import com.sedmelluq.discord.lavaplayer.track.DelegatedAudioTrack;
import com.sedmelluq.discord.lavaplayer.track.InternalAudioTrack;
import com.sedmelluq.discord.lavaplayer.track.playback.LocalAudioTrackExecutor;
import org.apache.http.NameValuePair;
import org.apache.http.client.utils.URIBuilder;
Expand Down Expand Up @@ -48,6 +51,9 @@ public void process(LocalAudioTrackExecutor executor) throws Exception {

for (var entry : config.entrySet()) {
var value = queryParams.getOrDefault(entry.getKey(), entry.getValue());
if (value == null) {
continue;
}
apiUri.addParameter(entry.getKey(), value);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,33 @@ public class FloweryTTSSourceManager implements AudioSourceManager, HttpConfigur

public static final String TTS_PREFIX = "ftts://";
private static final Logger log = LoggerFactory.getLogger(FloweryTTSSourceManager.class);
private static final int CHAR_MAX = 2000;
private static final int CHAR_MAX = 2048;
private static final int SILENCE_MIN = 0;
private static final int SILENCE_MAX = 10000;
private static final float SPEED_MIN = 0.5f;
private static final float SPEED_MAX = 10;

private final String voice;
private String voice = null;
private final HttpInterfaceManager httpInterfaceManager = HttpClientTools.createDefaultThreadLocalManager();
private boolean translate = false;
private int silence = 0;
private float speed = 1;
private String audioFormat = "mp3";

public FloweryTTSSourceManager() {
}

public FloweryTTSSourceManager(String voice) {
if (voice == null || voice.isEmpty()) {
throw new IllegalArgumentException("Default voice must be set");
}
this.voice = voice;
}

public void setVoice(String voice) {
this.voice = voice;
}

public void setTranslate(boolean translate) {
this.translate = translate;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
@Component
public class FloweryTTSConfig {

private String voice = "Aad";
private String voice = null;
private boolean translate;
private int silence;
private float speed = 1.0F;
Expand Down

0 comments on commit bfd5b47

Please sign in to comment.