Update app.py
Browse files
app.py
CHANGED
@@ -14,67 +14,6 @@ import io
|
|
14 |
import librosa
|
15 |
# import numpy
|
16 |
|
17 |
-
# pipeline = pipeline(task="image-classification", model="julien-c/hotdog-not-hotdog")
|
18 |
-
|
19 |
-
# st.title("Hot Dog? Or Not?")
|
20 |
-
|
21 |
-
# file_name = st.file_uploader("Upload a hot dog candidate image")
|
22 |
-
|
23 |
-
# if file_name is not None:
|
24 |
-
# col1, col2 = st.columns(2)
|
25 |
-
|
26 |
-
# image = Image.open(file_name)
|
27 |
-
# col1.image(image, use_column_width=True)
|
28 |
-
# predictions = pipeline(image)
|
29 |
-
|
30 |
-
# col2.header("Probabilities")
|
31 |
-
# for p in predictions:
|
32 |
-
# col2.subheader(f"{ p['label'] }: { round(p['score'] * 100, 1)}%")
|
33 |
-
|
34 |
-
# def read_as_single_channel_16k(audio_file, def_sr=16000, verbose=True, aim_second=None):
|
35 |
-
# assert os.path.exists(audio_file)
|
36 |
-
# st.markdown(os.path.exists(audio_file))
|
37 |
-
|
38 |
-
# file_extension = os.path.splitext(audio_file)[1].lower()
|
39 |
-
# st.markdown(file_extension)
|
40 |
-
|
41 |
-
# if file_extension == ".mp3":
|
42 |
-
# data, origin_sr = librosa.load(audio_file, sr=None)
|
43 |
-
# elif file_extension in [".wav", ".flac"]:
|
44 |
-
# data, origin_sr = soundfile.read(audio_file)
|
45 |
-
# else:
|
46 |
-
# raise Exception("unsupported file:" + file_extension)
|
47 |
-
|
48 |
-
# # channel check
|
49 |
-
# if len(data.shape) == 2:
|
50 |
-
# left_channel = data[:, 0]
|
51 |
-
# if verbose:
|
52 |
-
# print("Warning! the input audio has multiple chanel, this tool only use the first channel!")
|
53 |
-
# data = left_channel
|
54 |
-
|
55 |
-
# # sample rate check
|
56 |
-
# if origin_sr != def_sr:
|
57 |
-
# data = resampy.resample(data, origin_sr, def_sr)
|
58 |
-
# if verbose:
|
59 |
-
# print("Warning! The original samplerate is not 16Khz; the watermarked audio will be re-sampled to 16KHz")
|
60 |
-
|
61 |
-
# sr = def_sr
|
62 |
-
# audio_length_second = 1.0 * len(data) / sr
|
63 |
-
# # if verbose:
|
64 |
-
# # print("input length :%d second" % audio_length_second)
|
65 |
-
|
66 |
-
# if aim_second is not None:
|
67 |
-
# signal = data
|
68 |
-
# assert len(signal) > 0
|
69 |
-
# current_second = len(signal) / sr
|
70 |
-
# if current_second < aim_second:
|
71 |
-
# repeat_count = int(aim_second / current_second) + 1
|
72 |
-
# signal = np.repeat(signal, repeat_count)
|
73 |
-
# data = signal[0:sr * aim_second]
|
74 |
-
|
75 |
-
# return data, sr, audio_length_second
|
76 |
-
|
77 |
-
|
78 |
# def my_read_file(audio_path, max_second):
|
79 |
# signal, sr, audio_length_second = read_as_single_channel_16k(audio_path, default_sr)
|
80 |
# if audio_length_second > max_second:
|
|
|
14 |
import librosa
|
15 |
# import numpy
|
16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
# def my_read_file(audio_path, max_second):
|
18 |
# signal, sr, audio_length_second = read_as_single_channel_16k(audio_path, default_sr)
|
19 |
# if audio_length_second > max_second:
|