def get_voucher_audio(scriptId, audience, voice, template): print(f"⏳ Creating voucher audio for {audience[0]['username']}") # text to speech creation apiaudio.Speech().create(scriptId=scriptId, voice=voice, speed="110", audience=audience) # create mastering apiaudio.Mastering().create(scriptId=scriptId, soundTemplate=template, audience=audience) # retrieve mastered file filepath = apiaudio.Mastering().download(scriptId=scriptId, parameters=audience[0]) return filepath
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
# 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") # get url of audio tracks generated url = apiaudio.Mastering().retrieve(scriptId=scriptId, parameters=audience[0]) print(f"url to download the track: \n {url} \n") # or download file = apiaudio.Mastering().download(scriptId=scriptId,