AutoGPT
AutoGPT copied to clipboard
fix(macos_tts.py): remove URLs from the text before playing it with…
macOS TTS
Background
This Pull Request aims to improve the macOS TTS functionality by removing URLs from the text input before passing it to the TTS engine. The rationale is to improve the user experience when listening to the TTS output.
Changes
The following changes were made:
- Update the
_speech
function with an additional line of code to remove URLs from the input text using a regular expression.
import re
#... macOS TTS code ...
def _speech(self, text: str, voice_index: int = 0) -> bool:
text = re.sub(r'\b(?:https?://[-\w_.]+/?\w[-\w_.]*\.(?:[-\w_.]+/?\w[-\w_.]*\.)?[a-z]+(?:/[-\w_.%]+)*\b(?!\.))', '', text)
#... remaining macOS TTS code ...
- Imported the
re
library to handle regular expressions.
Documentation
The new code removes URLs from the input text using a regular expression. The re
library was imported to handle regex patterns, and the URLs are removed from the text using the re.sub
function. The code has an appropriate in-line comment explaining the purpose of the change.
Test Plan
- Test various input text strings containing URLs and verify that the URLs are removed from the TTS output.
- Test the functionality with multiple different voices to ensure compatibility.
PR Quality Checklist
- [x] My pull request is atomic and focuses on a single change.
- [x] I have thoroughly tested my changes with multiple different prompts.
- [x] I have considered potential risks and mitigations for my changes.
- [x] I have documented my changes clearly and comprehensively.
- [x] I have not snuck in any "extra" small tweaks changes
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Ignored Deployment
Name | Status | Preview | Comments | Updated (UTC) |
---|---|---|---|---|
docs | ⬜️ Ignored (Inspect) | Apr 26, 2023 1:35pm |
This is a mass message from the AutoGPT core team. Our apologies for the ongoing delay in processing PRs. This is because we are re-architecting the AutoGPT core!
For more details (and for infor on joining our Discord), please refer to: https://github.com/Significant-Gravitas/Auto-GPT/wiki/Architecting
Closed in favor of https://github.com/Significant-Gravitas/Auto-GPT/pull/4260
Thank you for your contribution!