inoftrobinson / inoft_vocal_framework

Create Alexa Skills, Google Actions, Samsung Bixby Capsules and Siri 'skills', with the same codebase. Then deploy automatically your app to AWS. All that in Python !
MIT License
9 stars 4 forks source link

Audio Block - Proposed syntax #23

Open inoftrobinson opened 3 years ago

inoftrobinson commented 3 years ago
audio_block_1 = AudioBlock()
track = audio_block_1.create_track(primary=True)
voices_sound = track.create_sound(file_url="voices.mp3", custom_key="voice", start=track.start)

track2 = audio_block_1.create_track(loop=True)
track2.create_sound(file_url="F:/Inoft/ambiance.mp3", custom_key="ambience", start=voices_sound.start + 2)

played_files: dict = self.play_audio_block(audio_block_1)
# structure : {"voice": {playedTime: 100}, "ambiance": {playedTime: 220}}
played_ambiance_file_infos: PlayedSoundInfos = played_files['ambiance']

audio_block_2 = AudioBlock()
track_2_1 = audio_block_2.create_track(primary=True)
track_2_1.create_sound(file_url="example.mp3", start=played_ambiance_file_infos.played_time)
self.play_audio_block(audio_block_2)
inoftrobinson commented 3 years ago

Implementation 1

audio_block_1 = AudioBlock()

track_voice = audio_block_1.create_track(primary=True, loop=False)
voice_sound = track_voice.create_sound(local_filepath=PollyClient().synthesize(
    text="Je suis un test d'audio dynamique ?",
    voice_id=VOICES.French_France_Female_CELINE.id,
    filepath_to_save_to="F:/Sons utiles/test_synthesised_dialogue.mp3"
), custom_key="voice", player_start=track_voice.start_time)
rifle_shots = track_voice.create_sound(
    local_filepath="F:/Sons utiles/Sound Effects/Guns/Automatic/238916__qubodup__rifle-shooting.flac",
    player_start=voice_sound.player_end_time + 20, player_end_time=voice_sound.player_end_time + 40
)

background_music_track = audio_block_1.create_track(primary=True)
background_music = background_music_track.create_sound(
    local_filepath="F:/Sons utiles/Musics/Vintage (1940s) French Music/CHANSON FRANCAISE 1930-1940 (192  kbps).mp3",
    player_start=background_music_track.start_time
)
background_music.change_volume(-1.0)
inoftrobinson commented 3 years ago

Dialogues in audio blocks

self.user_data.load(['player_name'])

audio_block_1 = AudioBlock()
track_1 = audio_block_1.create_track()

track_1.create_speech("Hello my dear friend, how are you ?", voice=VOICES.Joanna)
# Basic speech

track_1.create_speech(f"Do not let her disturb you {self.user_data.get('player_name')}, let's make cookies", voice=VOICES.Mathieu)
# Dynamic speech with user data preload (will raise if player_name not found, because no default value has been precised

Deprecate the self.say function, and turn the speech to a simple Speech to text json response, if there is no particular audio modiifications or displacement, and if the requested voice/voices are available to use natively on the target platform (Google Assistant, Alexa, etc)