Skip to content

Commit

Permalink
Extract to csv now available
Browse files Browse the repository at this point in the history
  • Loading branch information
Lokhia committed Jun 10, 2022
1 parent a98bb63 commit 5b793ff
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion notebooks/audio/gender_identification.py
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down Expand Up @@ -82,13 +82,18 @@ 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()
path_to_video = os.getenv("path_to_extract", "./")
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
Expand Down
2 changes: 1 addition & 1 deletion notebooks/audio/media_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 5b793ff

Please sign in to comment.