Esempio n. 1
0
def main(args):
    '''py script that allows to call the Genuis API to call retrieve lyrics from your favourite
       and render them trough the apiaudio API
       
       sample usage from CLI:
       python python/genius_and_apiaudio.py -a "Eminem" -s 'The Real Slim Shady' -v 'Joanna' -m 'full__fargalaxy_dark_father.wav' -e 'dark_father' 
       
       paramter
       -a   --artist            artist who sings your song, example: "Eminem"
       -s   --song              song from the given artist, example: "The Real Slim Shady"
       -v   --voice        voice from API.audio, example: "Joanna"
       -m   --mastering_sound   mastering background track, example: "full__fargalaxy_dark_father.wav"
       -e   --effect            efffect you want to apply over your voice, example: "dark_father"
    '''

    #print(apiaudio.Voice().list()) #use to print all available voices
    #print(apiaudio.Sound().list()) #use to print all available background tracks

    genius_api = genius.Genius(geniusCreds)
    song = genius_api.search_song(
        title=args.song, artist=args.artist, song_id=None,
        get_full_info=True)  #find the wanted song from a given artist
    replace_dict_clean_lyrics = {
        '\n': ' ',
        '\u0399': ' ',
        '[Intro]': ' ',
        '[Chorus]': ' ',
        '[Verse 1]': ' ',
        '[Verse 2]': ' ',
        '[Verse 3]': ' ',
        "\"": ' ',
        '"': ' ',
        '-': ' ',
        '—': ' '
    }
    lyrics = multiple_replace(
        replace_dict_clean_lyrics, song.lyrics
    )  #clean lyrics from a couple of predefined strings, feel free to add more depending on your song
    lyrics = re.sub(' +', ' ', lyrics)  #more cleaning

    # Create a new script and print the script created
    script = apiaudio.Script().create(
        scriptText="<<sectionName::lyrics>> " +
        lyrics[:500],  #full songs with background track can be quite difficult to handle thus we only render the first 500 characters
    )

    # create a text-to-speech
    response = apiaudio.Speech().create(
        scriptId=script["scriptId"],
        voice=args.aflr_voice,  #define voice
        speed=str(150),  #define voice speed
        effect=args.effect,  #define effects
    )
    print('response: ', response)

    audio_files = apiaudio.Speech().download(
        scriptId=script["scriptId"], destination=".")  #download raw speech

    apiaudio.Mastering().create(
        scriptId=script.get("scriptId"),
        backgroundTrackId=args.
        mastering_sound  #define mastering background track
    )

    url = apiaudio.Mastering().download(
        scriptId=script.get("scriptId"),
        destination=".")  #download mastered speech
Esempio n. 2
0
import apiaudio
apiaudio.api_key = "your-key"  # or define env variable: export apiaudio_key=<your-key>

text = "<<sectionName::welcome>> Hey {{username}}, welcome to my workout app!"
audience = [{"username": "******"}]

# script creation
script = apiaudio.Script().create(
    scriptText=text,
    projectName="workout_app",
    moduleName="welcome",
    scriptName="welcome-message",
)
print(f"Script created: \n {script} \n")

# get the scriptId from the script created.
scriptId = script["scriptId"]

# speech creation
response = apiaudio.Speech().create(scriptId=scriptId,
                                    voice="Joanna",
                                    speed="110",
                                    audience=audience)
print(f"Response from text-to-speech: \n {response} \n")

# mastering process
response = apiaudio.Mastering().create(scriptId=scriptId,
                                       soundTemplate="heatwave",
                                       audience=audience)
print(f"Response from mastering: \n {response} \n")
Esempio n. 3
0
        "voucher": "7 8 9",
        "template": "hourglass",
        "voice": "Matthew"
    },
    {
        "username": "******",
        "location": "luxemburg",
        "voucher": "a b c",
        "template": "openup",
        "voice": "Justin"
    },
]

text = "Hey {{username}}, Thanks for reaching out from {{location}}. Your voucher code is {{voucher}}. I will repeat one more time for you, {{username}}, your voucher code is {{voucher}}"
script = apiaudio.Script().create(scriptText=text,
                                  projectName="voucher_app",
                                  moduleName="winter_campaign",
                                  scriptName="voucher_2021")
scriptId = script["scriptId"]
print(f"✨ Script created with id: {scriptId}")

count = 1
files = []
for user in users:
    audience = [{
        "username": user["username"],
        "location": user["location"],
        "voucher": user["voucher"]
    }]
    file = get_voucher_audio(scriptId=scriptId,
                             audience=audience,
                             voice=user["voice"],
Esempio n. 4
0
import apiaudio
apiaudio.api_key = "your-key"  # or define env variable: export apiaudio_key=<your-key>

text = "<<sectionName::update>> Hey {{username}}, you are running at {{speed}} minutes per km and your heart rate is {{bpm}}."
audience = [{"username": "******", "speed": "4:40", "bpm": "152"}]

# script creation
script = apiaudio.Script().create(
    scriptText=text,
    projectName="workout_app",
    moduleName="running",
    scriptName="running_update",
)
print(f"Script created: \n {script} \n")

# get the scriptId from the script created.
scriptId = script["scriptId"]

# text to speech creation
response = apiaudio.Speech().create(
    scriptId=scriptId,
    voice="Joanna",
    speed="110",
    audience=audience,
)
print(f"Response from text-to-speech: \n {response} \n")

# get url of the speech file generated
url = apiaudio.Speech().retrieve(scriptId=scriptId)
print(f"url to download the speech track: \n {url} \n")
Esempio n. 5
0
import apiaudio
apiaudio.api_key = "your-key"  # or define env variable: export apiaudio_key=<your-key>
text = """<<sectionName::welcome>> Hey {{name}}, this is Evan Fleming calling from {{phonenumber}}.
 I thought of you because I’m working with an active footwear brand that’s seen about a 
 {{percent}} percent increase in reorders, and I think that I could help your brand do the same, 
 but I’m not exactly sure. So if you could give me a call back at {{phonenumber}}. Again, this is Evan. Thanks!"""
audience = [{
    "name": "Shelley",
    "percent": "20",
    "phonenumber": "1-2-3-4-5-6-7"
}]

# script creation
script = apiaudio.Script().create(
    scriptText=text,
    projectName="voicemail_example",
    moduleName="sales",
    scriptName="sales_example",
)
print(f"Script created: \n {script} \n")

# get the scriptId from the script created.
scriptId = script["scriptId"]

# speech creation
response = apiaudio.Speech().create(scriptId=scriptId,
                                    voice="Joanna",
                                    speed="120",
                                    audience=audience)
print(f"Response from text-to-speech: \n {response} \n")

# mastering process