Skip to content
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

New functions for unsupported endpoints + some modifications #41

Merged
merged 9 commits into from
Jun 4, 2023
Prev Previous commit
Next Next commit
multiple endpoints support
  • Loading branch information
theAbdoSabbagh committed Jun 3, 2023
commit 391fcaa954975e693004a22bef55e27a0b2b9751
31 changes: 31 additions & 0 deletions elevenlabs/api/voice.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,32 @@ def computed_settings(cls, v: VoiceSettings, values) -> VoiceSettings:
def delete(self):
API.delete(f"{api_base_url_v1}/voices/{self.voice_id}")

def edit_settings(self, stability: float, similarity_boost: float):
theAbdoSabbagh marked this conversation as resolved.
Show resolved Hide resolved
url = f"{api_base_url_v1}/voices/{self.voice_id}/settings/edit"
json = {
theAbdoSabbagh marked this conversation as resolved.
Show resolved Hide resolved
"stability": stability,
"similarity_boost": similarity_boost,
}
API.post(url, json=json)

def get_settings(self):
theAbdoSabbagh marked this conversation as resolved.
Show resolved Hide resolved
url = f"{api_base_url_v1}/voices/{self.voice_id}/settings"
return VoiceSettings(**API.get(url).json())

def get_info(self):
theAbdoSabbagh marked this conversation as resolved.
Show resolved Hide resolved
url = f"{api_base_url_v1}/voices/{self.voice_id}"
return Voice(**API.get(url).json())

def edit(self, name: str, labels: Optional[str] = None, description: Optional[str] = None):
theAbdoSabbagh marked this conversation as resolved.
Show resolved Hide resolved
url = f"{api_base_url_v1}/voices/{self.voice_id}/edit"
data = {
"name": name,
}
if labels: # Putting it as None will overwrite the labels
data["labels"] = labels
if description: # Putting it as None will overwrite the description
data["description"] = description
API.post(url, data=data)

class Voices(Listable, API):
voices: List[Voice]
Expand All @@ -146,6 +172,11 @@ def from_api(cls, api_key: Optional[str] = None):
url = f"{api_base_url_v1}/voices"
response = API.get(url).json()
return cls(**response)

@classmethod
def default_settings(cls):
theAbdoSabbagh marked this conversation as resolved.
Show resolved Hide resolved
url = f"{api_base_url_v1}/voices/settings/default"
return VoiceSettings(**API.get(url).json())

def add_clone(self, voice_clone: VoiceClone) -> Voice:
pass
Expand Down