Skip to content

Add previous_text context to ElevenLabsHttpTTSService #1600

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 3 commits into from
Apr 17, 2025

Conversation

markbackman
Copy link
Contributor

Please describe the changes in your PR. If it is addressing an issue, please reference that as well.

From 11Labs docs on previous_text:

The text that came before the text of the current request. Can be used to improve the speech’s continuity when concatenating together multiple generations or to influence the speech’s continuity in the current generation.

For HTTP requests, this parameter provides continuity between HTTP responses. We're passing in previous sentences from the bot's current turn.

Copy link

codecov bot commented Apr 16, 2025

Codecov Report

Attention: Patch coverage is 0% with 15 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/pipecat/services/elevenlabs/tts.py 0.00% 15 Missing ⚠️
Files with missing lines Coverage Δ
src/pipecat/services/elevenlabs/tts.py 0.00% <0.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment on lines +12 to +20
- Added `previous_text` context support to ElevenLabsHttpTTSService, improving
speech consistency across sentences within an LLM response.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, it makes a lot of sense.

Comment on lines 531 to 532
self._cumulative_time = 0
self._started = False
self._previous_text = ""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we create a clear or reset function to centralize where we are resetting these internal states ?

Comment on lines 539 to 540
self._started = False
self._cumulative_time = 0
self._previous_text = ""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like we are resetting the exactly same variables here.

# Include previous text as context if available
if self._previous_text:
payload["previous_text"] = self._previous_text
print(f"Previous text: {self._previous_text}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: should we keep it, maybe replace by logger ?

Copy link
Contributor Author

@markbackman markbackman Apr 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! My mistake.

Update: Actually, I'll just remove it. This log seems unnecessary.

Copy link
Contributor

@filipi87 filipi87 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some nits, but all looks good, nice improvement.

@markbackman markbackman force-pushed the mb/11labs-http-timestamps branch from 3bb1ff8 to 384f809 Compare April 17, 2025 01:55
@markbackman markbackman force-pushed the mb/11labs-previous-text branch from 4b21dab to 1e0a9d7 Compare April 17, 2025 02:22
@markbackman markbackman merged commit 7ff748d into mb/11labs-http-timestamps Apr 17, 2025
6 checks passed
@markbackman markbackman deleted the mb/11labs-previous-text branch April 17, 2025 02:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants