-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from andrew-hossack/dev
Version 0.0.2
- Loading branch information
Showing
18 changed files
with
326 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,2 @@ | ||
__pycache__ | ||
lib/AutoCompiler/private | ||
lib/AutoCompiler/temp | ||
lib/AutoCompiler/output | ||
lib/AutoCompiler/private.py | ||
dat/* | ||
__init__.pyc | ||
*.pyc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
include vidtools/video.yaml | ||
include vidtools/examples | ||
include vidtools/lib/refreshtokengen.py | ||
graft vidtools/dat |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,9 +3,12 @@ | |
with open("README.md", "r", encoding="utf-8") as fh: | ||
long_description = fh.read() | ||
|
||
# TODO Figure out how to include /examples, /lib, /dat | ||
# vidtools/private in the install | ||
|
||
setuptools.setup( | ||
name="VidTools", | ||
version="0.0.2", | ||
version="0.0.3", | ||
author="Andrew Hossack", | ||
author_email="[email protected]", | ||
description="VidTools is a video tools python package", | ||
|
@@ -22,10 +25,14 @@ | |
], | ||
packages=setuptools.find_packages(), | ||
python_requires=">=3.6", | ||
include_package_data=True, | ||
install_requires=[ | ||
"google-api-python-client", | ||
"TikTokApi", | ||
"oauth2client", | ||
"praw", | ||
"google-cloud", | ||
"google-cloud-core", | ||
"google-cloud-texttospeech" | ||
] | ||
) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
''' | ||
# @ Author: Andrew Hossack | ||
# @ Create Time: 2021-03-07 18:31:20 | ||
# @ Description: Text To Speech class | ||
''' | ||
|
||
from google.cloud import texttospeech | ||
import os | ||
from pathlib import Path | ||
|
||
class TTSHelper: | ||
''' | ||
Text to speech helper class | ||
https://googleapis.dev/python/texttospeech/latest/index.html | ||
''' | ||
def __init__(self, secrets_filepath, outfile_name='audio.mp3', **kwargs): | ||
''' | ||
args: | ||
secrets_filepath (str): | ||
Absolute path to secrets file json | ||
kwargs: | ||
outfile_name (str): name of audio output file | ||
Defaults to audio.mp3 | ||
''' | ||
self._text = None | ||
self._output_directory = Path(os.path.join(os.path.dirname(__file__))).joinpath('dat') | ||
self._secrets_filepath = Path(secrets_filepath) | ||
self._outfile_name = outfile_name | ||
self._client = texttospeech.TextToSpeechClient() | ||
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = self._secrets_filepath | ||
|
||
def synthesize_speech(self, text, language_code="en-US", ssml_gender=texttospeech.SsmlVoiceGender.NEUTRAL): | ||
"""Synthesizes speech from the input string of text or ssml. | ||
Note: ssml must be well-formed according to: | ||
https://www.w3.org/TR/speech-synthesis/ | ||
""" | ||
self._text = text | ||
|
||
# Set the text input to be synthesized | ||
synthesis_input = texttospeech.SynthesisInput(text=self._text) | ||
|
||
# Build the voice request, select the language code ("en-US") and the ssml | ||
# voice gender ("neutral") | ||
voice = texttospeech.VoiceSelectionParams( | ||
language_code=language_code, ssml_gender=ssml_gender | ||
) | ||
|
||
# Select the type of audio file you want returned | ||
audio_config = texttospeech.AudioConfig( | ||
audio_encoding=texttospeech.AudioEncoding.MP3 | ||
) | ||
|
||
# Perform the text-to-speech request on the text input with the selected | ||
# voice parameters and audio file type | ||
response = self._client.synthesize_speech( | ||
input=synthesis_input, voice=voice, audio_config=audio_config | ||
) | ||
|
||
# The response's audio_content is binary. | ||
with open(f'{self._output_directory}/{self._outfile_name}', "wb") as out: | ||
# Write the response to the output file. | ||
out.write(response.audio_content) | ||
print('Audio content written to file "output.mp3"') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.