<commit_before># TODO : Move aws_key stuff into letsrobot.conf

import boto3
from subprocess import Popen, PIPE
import os
import random

# to satisfy both python 2 and 3, goes away if keys are in conf
try:
    import secret
except ImportError:
    import tts.secret as secret

client = None
polly = None
voices = [ 'Nicole', 'Russell', 'Amy', 'Brian', 'Emma', 'Raveena', 'Ivy', 'Joanna', 'Joey', 'Justin',
             'Kendra', 'Kimberly', 'Mathew', 'Salli', 'Geraint' ]             
users = {}
robot_voice = None
hw_num = None

def setup(robot_config):
    global client
    global polly
    global robot_voice
    global users
    global hw_num
    
    owner = robot_config.get('robot', 'owner')
    owner_voice = robot_config.get('polly', 'owner_voice')
    robot_voice = robot_config.get('polly', 'robot_voice')
    hw_num = robot_config.getint('tts', 'hw_num')
    
    client = boto3.Session(aws_access_key_id=secret.aws_Key,
                            aws_secret_access_key=secret.aws_Secret,
                            region_name=secret.aws_Region)

    polly = boto3.client('polly', aws_access_key_id=secret.aws_Key,
                            aws_secret_access_key=secret.aws_Secret,
                            region_name=secret.aws_Region)
                            
    users[owner] = owner_voice
    
def say(message, *args):
    if (len(args) == 0): # simple say
        response = polly.synthesize_speech(
            OutputFormat = 'mp3',
            VoiceId = robot_voice,
            Text = message,
        )
    else:
        user = args[0]['name']

        if (args[0]['anonymous'] == True):
            voice = 'Mizuki'
        else:<commit_msg>Modified polly to use and extended command .new_voice to assign people a new random voice.<commit_after># TODO : Move aws_key stuff into letsrobot.conf

import boto3
from subprocess import Popen, PIPE
import os
import random
import extended_command

# to satisfy both python 2 and 3, goes away if keys are in conf
try:
    import secret
except ImportError:
    import tts.secret as secret

client = None
polly = None
voices = [ 'Nicole', 'Russell', 'Amy', 'Brian', 'Emma', 'Raveena', 'Ivy', 'Joanna', 'Joey', 'Justin',
             'Kendra', 'Kimberly', 'Mathew', 'Salli', 'Geraint' ]             
users = {}
robot_voice = None
hw_num = None

def new_voice(*args):
    global users

    print(args)
    if (args[1]['anonymous'] != True):
        users[args[1]['name']] = random.choice(voices)
   
    

def setup(robot_config):
    global client
    global polly
    global robot_voice
    global users
    global hw_num
    
    owner = robot_config.get('robot', 'owner')
    owner_voice = robot_config.get('polly', 'owner_voice')
    robot_voice = robot_config.get('polly', 'robot_voice')
    hw_num = robot_config.getint('tts', 'hw_num')
    
    client = boto3.Session(aws_access_key_id=secret.aws_Key,
                            aws_secret_access_key=secret.aws_Secret,
                            region_name=secret.aws_Region)

    polly = boto3.client('polly', aws_access_key_id=secret.aws_Key,
                            aws_secret_access_key=secret.aws_Secret,
                            region_name=secret.aws_Region)
                            
    users[owner] = owner_voice
    
    if robot_config.getboolean('tts', 'ext_chat'): #ext_chat enabled, add voice command
        extended_command.add_command('.new_voice', new_voice)
        
def say(message, *args):
    if (len(args) == 0): # simple say
        response = polly.synthesize_speech(
            OutputFormat = 'mp3',
            VoiceId = robot_voice,
            Text = message,
        )
    else:
        user = args[0]['name']

        if (args[0]['anonymous'] == True):
            voice = 'Mizuki'
        else:
{'fraction_non_alphanumeric': 0.10996290408055114, 'fraction_numerical': 0.005299417064122946, 'mean_word_length': 2.3917340521114108, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '598006', 'n_tokens_mistral': 1212, 'n_tokens_neox': 1188, 'n_words': 287}