-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinput_file.py
54 lines (41 loc) · 1.78 KB
/
input_file.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import argparse
import pprint
from analyze_with_gemini2 import Analyzer_With_GenAI
from analyze_with_librosa import AudioAnalyzer
from analyze_with_mutagen import Analyzer_With_Mutagen
import pydub
def main():
parser = argparse.ArgumentParser()
parser.add_argument("FILE_PATH")
parse = parser.parse_args()
FILE_PATH = parse.FILE_PATH
if ".wav" in FILE_PATH:
print("wavファイルです! mp3に変換します!")
sound = pydub.AudioSegment.from_wav(FILE_PATH)
sound.export(FILE_PATH.replace(".wav", ".mp3"), format="mp3", bitrate="96k")
FILE_PATH = FILE_PATH.replace(".wav", ".mp3")
elif ".mp3" in FILE_PATH:
print("mp3ファイルです! ビットレートを96kに変換します!")
sound = pydub.AudioSegment.from_mp3(FILE_PATH)
sound.export(FILE_PATH + ".96.mp3", format="mp3", bitrate="96k")
elif ".flac" in FILE_PATH:
print("flacファイルです! mp3に変換します!")
sound = pydub.AudioSegment.from_file(FILE_PATH, format="flac")
sound.export(FILE_PATH.replace(".flac", ".mp3"), format="mp3", bitrate="96k")
FILE_PATH = FILE_PATH.replace(".flac", ".mp3")
else:
print("wavでもmp3でもflacでもありません!")
return
print("Librosaで解析します!")
analyzed = AudioAnalyzer(file_path=FILE_PATH).analyze_technical_features()
print("Mutagenで解析します!")
mutagenized = Analyzer_With_Mutagen(FILE_PATH).analyze()
print("GenAIで解析します!")
geminized = Analyzer_With_GenAI(FILE_PATH).analyze(
refference=(analyzed | mutagenized)
)
all_data = analyzed | geminized | mutagenized
pprint.pprint(all_data)
if all_data["error"] == True:
print("エラーです!")
main()