-
Notifications
You must be signed in to change notification settings - Fork 2.1k
feat: add Fish Audio TTS support #2434
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
8a43bd9
feat: add Fish Audio TTS support and configuration options
twangodev 0fae29a
refactor: remove hardcoded video codec from final_video.py
twangodev 33c94a7
fixup: Format Python code with Black
github-actions[bot] 408c82a
fix: revert compatibility for non-nvidia machines
twangodev 808efd2
refactor: streamline FishAudio client import and save utility usage
twangodev aa44633
fix: revert compatibility for prepare_background
twangodev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| import random | ||
|
|
||
| from utils import settings | ||
|
|
||
|
|
||
| class FishAudio: | ||
| def __init__(self): | ||
| self.max_chars = 5000 | ||
| self.client = None | ||
| self.voices = [ | ||
| "8ef4a238714b45718ce04243307c57a7", # E-girl | ||
| "802e3bc2b27e49c2995d23ef70e6ac89", # Energetic Male | ||
| "933563129e564b19a115bedd57b7406a", # Sarah | ||
| "bf322df2096a46f18c579d0baa36f41d", # Adrian | ||
| "b347db033a6549378b48d00acb0d06cd", # Selene | ||
| "536d3a5e000945adb7038665781a4aca", # Ethan | ||
| ] | ||
|
|
||
| def run(self, text, filepath, random_voice: bool = False): | ||
| if self.client is None: | ||
| self.initialize() | ||
|
|
||
| if random_voice: | ||
| voice_id = self.randomvoice() | ||
| else: | ||
| voice_id = str(settings.config["settings"]["tts"]["fishaudio_voice"]) | ||
|
|
||
| audio = self.client.tts.convert(text=text, reference_id=voice_id) | ||
|
|
||
| from fishaudio.utils import save | ||
|
|
||
| save(audio, filepath) | ||
|
|
||
| def initialize(self): | ||
| from fishaudio import FishAudio as FishAudioClient | ||
|
|
||
| api_key = settings.config["settings"]["tts"].get("fishaudio_api_key") | ||
| if not api_key: | ||
| raise ValueError( | ||
| "You didn't set a Fish Audio API key! Please set the config variable fishaudio_api_key to a valid API key." | ||
| ) | ||
|
|
||
| self.client = FishAudioClient(api_key=api_key) | ||
|
|
||
| def randomvoice(self): | ||
| return random.choice(self.voices) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| boto3==1.36.8 | ||
| botocore==1.36.8 | ||
| fish-audio-sdk==1.1.0 | ||
| gTTS==2.5.4 | ||
| moviepy==2.2.1 | ||
| playwright==1.49.1 | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.