From 5b793fffee5104e193e3c1a1f61a35511c1fed92 Mon Sep 17 00:00:00 2001 From: Lokhia Date: Fri, 10 Jun 2022 23:12:46 +0200 Subject: [PATCH] Extract to csv now available --- notebooks/audio/gender_identification.py | 7 ++++++- notebooks/audio/media_tools.py | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/notebooks/audio/gender_identification.py b/notebooks/audio/gender_identification.py index 5aec1ba..54a9562 100644 --- a/notebooks/audio/gender_identification.py +++ b/notebooks/audio/gender_identification.py @@ -41,7 +41,7 @@ def search_gender_tag(self, time): # Give a time in seconds def compute_speaking_time_allocation(self): speaking_time = {'male': 0, 'female': 0} - dif = pd.Series(self.gendered_audio_seg['end']-self.gendered_audio_seg['start'], name='time_frame') + dif = pd.Series(self.gendered_audio_seg['end'] - self.gendered_audio_seg['start'], name='time_frame') totaldf = pd.concat([self.gendered_audio_seg['gender'], dif], axis=1) for i in totaldf.index: if totaldf['gender'][i] == 'male': @@ -82,6 +82,10 @@ def run_speech_to_text(self): axis=1) return transcription + def export_to_csv(self, file_path): + result = pd.concat([self.gendered_audio_seg, self.dialogues['transcription']], axis=1) + result.to_csv(path_or_buf=file_path, sep=";", header=True, index=False) + if __name__ == '__main__': load_dotenv() @@ -89,6 +93,7 @@ def run_speech_to_text(self): audio = os.getenv("path_to_audio", "./") movie = Movie(path_to_video, audio) print(movie.dialogues) + movie.export_to_csv('./HP4_results.csv') # """Pour convertir en tests :""" # gender_of_time_45 = movie.search_gender_tag(45) # None # gender_of_time_60 = movie.search_gender_tag(60) # Male diff --git a/notebooks/audio/media_tools.py b/notebooks/audio/media_tools.py index b448811..b2733f7 100644 --- a/notebooks/audio/media_tools.py +++ b/notebooks/audio/media_tools.py @@ -28,7 +28,7 @@ def extract_audio_from_movie(file, extension='.wav'): path_to_extract = os.getenv("path_to_extract", "./") path_to_trailer = os.getenv("path_to_trailer", "./") - extract_audio_from_movie(path_to_extract) + extract_audio_from_movie(path_to_full_movie) # separate_voice_and_music(path_to_extract) # cut_and_save(path_to_full_movie, 2115, 2491, path_to_extract)