AutoGPT icon indicating copy to clipboard operation
AutoGPT copied to clipboard

fix(macos_tts.py): remove URLs from the text before playing it with…

Open DevMentat opened this issue 1 year ago • 1 comments

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:

  1. 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 ...
  1. 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

  1. Test various input text strings containing URLs and verify that the URLs are removed from the TTS output.
  2. 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

DevMentat avatar Apr 26 '23 13:04 DevMentat

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

vercel[bot] avatar Apr 26 '23 13:04 vercel[bot]

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

p-i- avatar May 05 '23 00:05 p-i-

Closed in favor of https://github.com/Significant-Gravitas/Auto-GPT/pull/4260

Thank you for your contribution!

gravelBridge avatar May 17 '23 03:05 gravelBridge