|
|
@ -1,6 +1,6 @@
|
|
|
|
#!/usr/bin/env python3
|
|
|
|
#!/usr/bin/env python3
|
|
|
|
from boto3 import Session
|
|
|
|
from boto3 import Session
|
|
|
|
from botocore.exceptions import BotoCoreError, ClientError
|
|
|
|
from botocore.exceptions import BotoCoreError, ClientError, ProfileNotFound
|
|
|
|
import sys
|
|
|
|
import sys
|
|
|
|
from utils import settings
|
|
|
|
from utils import settings
|
|
|
|
import random
|
|
|
|
import random
|
|
|
@ -30,6 +30,7 @@ class AWSPolly:
|
|
|
|
self.voices = voices
|
|
|
|
self.voices = voices
|
|
|
|
|
|
|
|
|
|
|
|
def run(self, text, filepath, random_voice: bool = False):
|
|
|
|
def run(self, text, filepath, random_voice: bool = False):
|
|
|
|
|
|
|
|
try:
|
|
|
|
session = Session(profile_name="polly")
|
|
|
|
session = Session(profile_name="polly")
|
|
|
|
polly = session.client("polly")
|
|
|
|
polly = session.client("polly")
|
|
|
|
if random_voice:
|
|
|
|
if random_voice:
|
|
|
@ -61,6 +62,13 @@ class AWSPolly:
|
|
|
|
# The response didn't contain audio data, exit gracefully
|
|
|
|
# The response didn't contain audio data, exit gracefully
|
|
|
|
print("Could not stream audio")
|
|
|
|
print("Could not stream audio")
|
|
|
|
sys.exit(-1)
|
|
|
|
sys.exit(-1)
|
|
|
|
|
|
|
|
except ProfileNotFound:
|
|
|
|
|
|
|
|
print("You need to install the AWS CLI and configure your profile")
|
|
|
|
|
|
|
|
print("""
|
|
|
|
|
|
|
|
Linux: https://docs.aws.amazon.com/polly/latest/dg/setup-aws-cli.html
|
|
|
|
|
|
|
|
Windows: https://docs.aws.amazon.com/polly/latest/dg/install-voice-plugin2.html
|
|
|
|
|
|
|
|
""")
|
|
|
|
|
|
|
|
sys.exit(-1)
|
|
|
|
|
|
|
|
|
|
|
|
def randomvoice(self):
|
|
|
|
def randomvoice(self):
|
|
|
|
return random.choice(self.voices)
|
|
|
|
return random.choice(self.voices)
|
|
|
|