Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions gui/asset_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ def getElevenlabsVoices(cls):
voices = list(reversed(ElevenLabsAPI(api_key).get_voices().keys()))
return voices

@classmethod
def _pickDefaultVoice(cls, choices, preferred="Chris"):
'''Pick a default voice from choices, tolerating ElevenLabs' descriptive
voice names (e.g. "Chris - Charming, Down-to-Earth") instead of a bare match.'''
for choice in choices:
if choice == preferred or choice.startswith(f"{preferred} -") or choice.startswith(f"{preferred} "):
return choice
return choices[0] if choices else None

@classmethod
def start_file(cls, path):
if platform.system() == "Windows":
Expand Down Expand Up @@ -77,10 +86,11 @@ def voiceChoice(cls, provider: str = None):
provider = cls.ELEVEN_TTS
if cls.instance_voiceChoice.get(provider, None) is None:
if provider == cls.ELEVEN_TTS:
choices = cls.getElevenlabsVoices()
cls.instance_voiceChoice[provider] = gr.Radio(
cls.getElevenlabsVoices(),
choices,
label="Elevenlabs voice",
value="Chris",
value=cls._pickDefaultVoice(choices),
interactive=True,
)
return cls.instance_voiceChoice[provider]
Expand All @@ -91,10 +101,11 @@ def voiceChoiceTranslation(cls, provider: str = None):
provider = cls.ELEVEN_TTS
if cls.instance_voiceChoiceTranslation.get(provider, None) is None:
if provider == cls.ELEVEN_TTS:
choices = cls.getElevenlabsVoices()
cls.instance_voiceChoiceTranslation[provider] = gr.Radio(
cls.getElevenlabsVoices(),
choices,
label="Elevenlabs voice",
value="Chris",
value=cls._pickDefaultVoice(choices),
interactive=True,
)
return cls.instance_voiceChoiceTranslation[provider]
6 changes: 4 additions & 2 deletions shortGPT/config/asset_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,17 @@ def get_df(cls, source=None) -> pd.DataFrame:
cls.sync_local_assets()
data = []
if source is None or source == 'local':
for key, asset in cls.local_assets._get().items():
# TinyMongo can transiently return None right after a write from
# sync_local_assets() above; treat that as "no assets yet" rather than crash.
for key, asset in (cls.local_assets._get() or {}).items():
data.append({'name': key,
'type': asset['type'],
'link': asset['path'],
'source': 'local',
'ts': asset.get('ts')
})
if source is None or source == 'youtube':
for key, asset in cls.remote_assets._get().items():
for key, asset in (cls.remote_assets._get() or {}).items():
data.append({'name': key,
'type': asset['type'],
'link': asset['url'],
Expand Down