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

streamlabspolly_fix.py #1966

Merged
merged 1 commit into from
Mar 1, 2024
Merged

streamlabspolly_fix.py #1966

merged 1 commit into from
Mar 1, 2024

Conversation

dyogenez
Copy link
Contributor

@dyogenez dyogenez commented Feb 23, 2024

fixes the streamlabspolly error:

Error occurred calling Streamlabs Polly

Description

Summary of Change and Issue Fixed:

This update modifies the streamlabs_polly.py file within the Text-to-Speech (TTS) module to address issues related to HTTP request headers not being properly set for requests to the Streamlabs service. The issue arises due to Streamlabs' API requiring a "Referer" header for requests, which was previously not included, leading to failed API calls.

Context:

The streamlabs_polly.py script is used to interact with Streamlabs for converting text to speech. Recent changes or restrictions imposed by Streamlabs necessitate the inclusion of a "Referer" header in API requests to ensure successful communication with their service.

Dependencies Required:

  • requests: This Python library is used for making HTTP requests. Ensure that you have this library installed in your project environment.

Detailed Instructions:

  1. Locate the streamlabs_polly.py File:

    • Navigate to the TTS directory in your project and find the streamlabs_polly.py file.
  2. Open the File:

    • Open streamlabs_polly.py in a text editor or IDE of your choice that supports Python syntax, such as Visual Studio Code, PyCharm, or Sublime Text.
  3. Modify the Code:

    • Find the code snippet around line 46 (note: the line number may vary if the file has been previously altered):
      body = {"voice": voice, "text": text, "service": "polly"}
    • Directly below this line, insert the new code blocks to add the necessary headers and make the post request:
      headers = {"Referer": "https://streamlabs.com/"}
      response = requests.post(self.url, headers=headers, data=body)
    • Ensure that these new lines of code are correctly indented to match the Python file's existing code style and structure.
  4. Save the Changes:

    • Save the file by pressing CTRL+S (or Cmd+S on macOS) or using your text editor's save function.
  5. Test the Changes:

    • Run main.py or the relevant script that utilizes the modified streamlabs_polly.py to verify that the issue has been resolved and the TTS functionality is working as expected.

By following these instructions, you will have adjusted the streamlabs_polly.py file to include the required "Referer" header in requests to Streamlabs, addressing the compatibility issue and ensuring the smooth operation of the TTS feature in your project.

Issue Fixes

Issue Fix Summary:

Modified streamlabs_polly.py to include "Referer" headers in requests, fixing the "Error occurred calling Streamlabs Polly" issue by ensuring compliance with Streamlabs API requirements.

  • Changes:
    • Added headers = {"Referer": "https://streamlabs.com/"} before API requests.
    • Ensured requests include these headers: response = requests.post(self.url, headers=headers, data=body).

Result: Eliminated the error and restored functionality to Streamlabs Polly requests in the TTS module.

None

Checklist:

  • [✔️ ] I am pushing changes to the develop branch
  • [✔️ ] I am using the recommended development environment
  • [✔️ ] I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • [✔️ ] I have formatted and linted my code using python-black and pylint
  • [✔️ ] I have cleaned up unnecessary files
  • [✔️ ] My changes generate no new warnings
  • [✔️ ] My changes follow the existing code-style
  • [✔️ ] My changes are relevant to the project

Any other information (e.g how to test the changes)

None

fixes the streamlabspolly error:

Error occurred calling Streamlabs Polly
@github-actions github-actions bot added the stale label Mar 1, 2024
@JasonLovesDoggo JasonLovesDoggo merged commit 91c2b09 into elebumm:master Mar 1, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants