History item¶
- class HistoryItem(data: dict, parentUser: User)¶
Represents a previously generated audio.
Tip
There is no method to get an Voice object for the voice that was used to create the file as it may not exist anymore. You can use the voiceID for that.
- property metadata¶
All the metadata associated with the item.
- property generation_settings¶
The settings used for this generation, as a GenerationOptions object.
Warning
- The following properties will be missing/invalid in the returned GenerationOptions due to the API not providing them:
latencyOptimizationLevel will be set to -99
- property parentUser¶
The User object for the user that generated this item.
- property voiceId¶
The voiceID of the voice used.
- property voiceCategory¶
The type of voice used.
- property source¶
Whether the item was generated using TTS or STS.
- property characterCountChangeAmount¶
How many characters this generation used.
- property filename¶
The filename the audio will have.
Note
There is a discrepancy in the timestamp. When returned through the website, they have spaces. In the API, they have underscores.
- get_audio_bytes() bytes ¶
Retrieves the audio bytes associated with the history item.
Note
The audio will be cached so that it’s not downloaded every time this is called.
Error
The history currently saves PCM generations directly, without any header data. Since the samplerate isn’t saved either, you’ll basically just need to guess which samplerate it is if trying to play it back.
Caution
If you’re looking to download multiple history items, use User.download_history_items() instead. That will call a different endpoint, optimized for multiple downloads.
- Returns:
The bytes of the mp3 file.
- Return type:
bytes
- play_audio_v2(playbackOptions: ~elevenlabslib.helpers.PlaybackOptions = PlaybackOptions(runInBackground=False, portaudioDeviceID=None, onPlaybackStart=<function PlaybackOptions.<lambda>>, onPlaybackEnd=<function PlaybackOptions.<lambda>>, audioPostProcessor=<function PlaybackOptions.<lambda>>)) OutputStream ¶
Plays the audio associated with the history item.
- Parameters:
playbackOptions (PlaybackOptions) – Options for the audio playback such as the device to use and whether to run in the background.
- Returns:
The sounddevice OutputStream of the playback.
Error
Due to the lack of samplerate information, when playing back a generation created with PCM, the library assumes it was made using the highest samplerate available to your account. Additionally, we’re assuming the file is using PCM rather than ULAW.
If either of the above assumptions isn’t true, simply use the audio functions in helpers.py to play back the audio yourself.
- fetch_feedback()¶
Fetches the feedback information associated with this generation.
- edit_feedback(thumbsUp: bool, feedbackText: str = '', issueTypes: list[str] | None = None)¶
Allows you to leave feedback for this generation.
- Parameters:
thumbsUp – Whether or not to rate the generation positively.
feedbackText – Any text you’d like to add as feedback. Only sent if thumbsUp is true, in which case it must be at least 50 characters.
issueTypes – A list of types of issues this generation falls under. Only sent if thumbsUp is false.
Note
The valid values for issueTypes are: emotions, inaccurate_clone, glitches, audio_quality, other
Other values will be ignored.
Caution
You CANNOT add positive feedback to items that are “too long”. I’m afraid there’s no specified maximum duration. If an item is too long, a ValueError will be thrown.
- delete()¶
Deletes the item from your history.
- class ElevenLabsHistoryItem(*args, **kwargs)¶