Spaces:
Sleeping
Sleeping
Luis
commited on
Commit
•
97249f0
1
Parent(s):
d04e351
init2
Browse files- .gitattributes +5 -0
- .gitignore +3 -0
- __pycache__/test.cpython-38.pyc +0 -0
- app.py +99 -0
- python/__init__.py +0 -0
- python/__pycache__/__init__.cpython-38.pyc +0 -0
- python/tensorflow_audio_task.ipynb +201 -0
- python/util/__init__.py +0 -0
- python/util/__pycache__/__init__.cpython-38.pyc +0 -0
- python/util/__pycache__/audio_util.cpython-38.pyc +0 -0
- python/util/__pycache__/plt_util.cpython-38.pyc +0 -0
- python/util/__pycache__/str_util.cpython-38.pyc +0 -0
- python/util/__pycache__/tensorflow_util.cpython-38.pyc +0 -0
- python/util/__pycache__/time_util.cpython-38.pyc +0 -0
- python/util/apnea_util.py +20 -0
- python/util/audio_util.py +24 -0
- python/util/plt_util.py +117 -0
- python/util/str_util.py +6 -0
- python/util/tensorflow_util.py +28 -0
- python/util/time_util.py +5 -0
- requirements.txt +10 -0
- res/lite-model_yamnet_classification_tflite_1.tflite +3 -0
- res/yamnet_class_map.csv +522 -0
- test.py +162 -0
.gitattributes
CHANGED
@@ -33,3 +33,8 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
<<<<<<< HEAD
|
37 |
+
=======
|
38 |
+
*.wav filter=lfs diff=lfs merge=lfs -text
|
39 |
+
*.mp4 filter=lfs diff=lfs merge=lfs -text
|
40 |
+
>>>>>>> 98229b1 (init)
|
.gitignore
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
.DS_Store
|
2 |
+
.ipynb_checkpoints/
|
3 |
+
.idea/
|
__pycache__/test.cpython-38.pyc
ADDED
Binary file (4.77 kB). View file
|
|
app.py
ADDED
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from test import predict_uri
|
3 |
+
import sys
|
4 |
+
import warnings
|
5 |
+
from fastapi import FastAPI
|
6 |
+
|
7 |
+
# ignore UserWarning
|
8 |
+
warnings.simplefilter("ignore", UserWarning)
|
9 |
+
|
10 |
+
examples = [
|
11 |
+
['res/miaow_16k.wav'],
|
12 |
+
['res/snore/pro_snore 6bee45643b45af9b_a7a3bbe6ba79af5b25b19ad10a8d9421d0d5679b.wav'],
|
13 |
+
['res/snore/Snoring vs Sleep Apnea - What the difference sounds like.mp4']
|
14 |
+
]
|
15 |
+
title = "yamnet test"
|
16 |
+
description = "An audio event classifier trained on the AudioSet dataset to predict audio events from the AudioSet ontology."
|
17 |
+
|
18 |
+
# # https://github.com/gradio-app/gradio/issues/2362
|
19 |
+
# class Logger:
|
20 |
+
# def __init__(self, filename):
|
21 |
+
# self.terminal = sys.stdout
|
22 |
+
# self.log = open(filename, "w")
|
23 |
+
#
|
24 |
+
# def write(self, message):
|
25 |
+
# self.terminal.write(message)
|
26 |
+
# self.log.write(message)
|
27 |
+
#
|
28 |
+
# def flush(self):
|
29 |
+
# self.terminal.flush()
|
30 |
+
# self.log.flush()
|
31 |
+
#
|
32 |
+
# def isatty(self):
|
33 |
+
# return False
|
34 |
+
#
|
35 |
+
#
|
36 |
+
# sys.stdout = Logger("output.log")
|
37 |
+
#
|
38 |
+
#
|
39 |
+
# def test(x):
|
40 |
+
# print("This is a test")
|
41 |
+
# print(f"Your function is running with input {x}...")
|
42 |
+
# return x
|
43 |
+
#
|
44 |
+
#
|
45 |
+
# def read_logs():
|
46 |
+
# sys.stdout.flush()
|
47 |
+
# with open("output.log", "r") as f:
|
48 |
+
# return f.read()
|
49 |
+
#
|
50 |
+
#
|
51 |
+
# with gr.Interface(predict_uri, inputs=gr.inputs.Audio(type="filepath"), outputs=["text", 'plot']) as demo:
|
52 |
+
# examples = examples,
|
53 |
+
# title = title,
|
54 |
+
# description = description,
|
55 |
+
# allow_flagging = 'never'
|
56 |
+
#
|
57 |
+
# logs = gr.Textbox()
|
58 |
+
# demo.load(read_logs, None, logs, every=1)
|
59 |
+
#
|
60 |
+
# demo.launch(enable_queue=True, show_error=True)
|
61 |
+
|
62 |
+
|
63 |
+
# with gr.Blocks() as demo:
|
64 |
+
# with gr.Row():
|
65 |
+
# inputs = gr.inputs.Audio(type="filepath")
|
66 |
+
# outputs = ["text", 'plot']
|
67 |
+
# btn = gr.Button("Run")
|
68 |
+
# btn.click(predict_uri, inputs, outputs)
|
69 |
+
#
|
70 |
+
# logs = gr.Textbox()
|
71 |
+
# demo.load(read_logs, None, logs, every=1)
|
72 |
+
#
|
73 |
+
# demo.queue().launch()
|
74 |
+
|
75 |
+
|
76 |
+
demo = gr.Interface(
|
77 |
+
predict_uri,
|
78 |
+
inputs=gr.inputs.Audio(type="filepath"),
|
79 |
+
outputs=['image', 'image', 'image', 'text', 'text', 'text', 'text'],
|
80 |
+
examples=examples,
|
81 |
+
title=title,
|
82 |
+
description=description,
|
83 |
+
allow_flagging='never'
|
84 |
+
)
|
85 |
+
demo.launch(enable_queue=True, show_error=True, share=False)
|
86 |
+
|
87 |
+
# # FastAPI
|
88 |
+
# CUSTOM_PATH = "/gradio"
|
89 |
+
#
|
90 |
+
# app = FastAPI()
|
91 |
+
#
|
92 |
+
#
|
93 |
+
# @app.get("/")
|
94 |
+
# def read_main():
|
95 |
+
# return {"message": "This is your main app"}
|
96 |
+
#
|
97 |
+
#
|
98 |
+
# io = gr.Interface(lambda x: "Hello, " + x + "!", "textbox", "textbox")
|
99 |
+
# app = gr.mount_gradio_app(app, io, path=CUSTOM_PATH)
|
python/__init__.py
ADDED
File without changes
|
python/__pycache__/__init__.cpython-38.pyc
ADDED
Binary file (149 Bytes). View file
|
|
python/tensorflow_audio_task.ipynb
ADDED
@@ -0,0 +1,201 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "markdown",
|
5 |
+
"metadata": {
|
6 |
+
"id": "LYKNvTdSQzAo"
|
7 |
+
},
|
8 |
+
"source": [
|
9 |
+
"https://www.tensorflow.org/lite/inference_with_metadata/task_library/audio_classifier?hl=zh-cn&authuser=1\n",
|
10 |
+
"\n",
|
11 |
+
"用 Python 运行推断\n",
|
12 |
+
"\n",
|
13 |
+
"第 1 步:安装 pip 软件包\n",
|
14 |
+
"\n",
|
15 |
+
"\n",
|
16 |
+
"pip install tflite-support\n",
|
17 |
+
"\n",
|
18 |
+
"注:Task Library 的 Audio API依靠 PortAudio 来录制来自设备麦克风的音频。如果您打算使用 Task Library 的 AudioRecord 进行音频录制,则需要在您的系统上安装 PortAudio。\n",
|
19 |
+
"\n",
|
20 |
+
"Linux:运行 sudo apt-get update && apt-get install libportaudio2\n",
|
21 |
+
"Mac 和 Windows:安装 tflite-support pip 软件包时会自动安装 PortAudio。\n",
|
22 |
+
"第 2 步:使用模型\n",
|
23 |
+
"\n",
|
24 |
+
"\n",
|
25 |
+
"\n",
|
26 |
+
"请参阅源代码,了解有关配置 AudioClassifier 的更多选项。"
|
27 |
+
]
|
28 |
+
},
|
29 |
+
{
|
30 |
+
"cell_type": "code",
|
31 |
+
"execution_count": 2,
|
32 |
+
"metadata": {
|
33 |
+
"colab": {
|
34 |
+
"base_uri": "https://localhost:8080/"
|
35 |
+
},
|
36 |
+
"id": "0hQPjUA6RLgz",
|
37 |
+
"outputId": "e2080672-4938-4cac-a361-71d047fdc17c"
|
38 |
+
},
|
39 |
+
"outputs": [
|
40 |
+
{
|
41 |
+
"name": "stdout",
|
42 |
+
"output_type": "stream",
|
43 |
+
"text": [
|
44 |
+
"Looking in indexes: https://mirrors.aliyun.com/pypi/simple\n",
|
45 |
+
"Collecting tflite-support\n",
|
46 |
+
" Downloading https://mirrors.aliyun.com/pypi/packages/3e/84/0a17a606f6d1560ba8f45186730d29cd917c2a55260fd6f4a13c121eee31/tflite_support-0.4.3-cp38-cp38-macosx_10_11_x86_64.whl (53.0 MB)\n",
|
47 |
+
"\u001b[K |████████████████████████████████| 53.0 MB 284 kB/s eta 0:00:01 |██████████████ | 23.3 MB 285 kB/s eta 0:01:45 |███████████████████████▍ | 38.6 MB 274 kB/s eta 0:00:53\n",
|
48 |
+
"\u001b[?25hCollecting sounddevice>=0.4.4\n",
|
49 |
+
" Downloading https://mirrors.aliyun.com/pypi/packages/24/5a/c0b9066fcaf783054b3f35254938dcba2d8cf02576ebdc56b6b4e85661f2/sounddevice-0.4.6-py3-none-macosx_10_6_x86_64.macosx_10_6_universal2.whl (107 kB)\n",
|
50 |
+
"\u001b[K |████████████████████████████████| 107 kB 676 kB/s eta 0:00:01\n",
|
51 |
+
"\u001b[?25hCollecting numpy>=1.20.0\n",
|
52 |
+
" Downloading https://mirrors.aliyun.com/pypi/packages/11/10/943cfb579f1a02909ff96464c69893b1d25be3731b5d3652c2e0cf1281ea/numpy-1.24.4-cp38-cp38-macosx_10_9_x86_64.whl (19.8 MB)\n",
|
53 |
+
"\u001b[K |████████████████████████████████| 19.8 MB 278 kB/s eta 0:00:01\n",
|
54 |
+
"\u001b[?25hCollecting flatbuffers>=2.0\n",
|
55 |
+
" Downloading https://mirrors.aliyun.com/pypi/packages/6f/12/d5c79ee252793ffe845d58a913197bfa02ae9a0b5c9bc3dc4b58d477b9e7/flatbuffers-23.5.26-py2.py3-none-any.whl (26 kB)\n",
|
56 |
+
"Requirement already satisfied: absl-py>=0.7.0 in /Users/luis/miniconda3/lib/python3.8/site-packages (from tflite-support) (0.13.0)\n",
|
57 |
+
"Collecting pybind11>=2.6.0\n",
|
58 |
+
" Downloading https://mirrors.aliyun.com/pypi/packages/06/55/9f73c32dda93fa4f539fafa268f9504e83c489f460c380371d94296126cd/pybind11-2.11.1-py3-none-any.whl (227 kB)\n",
|
59 |
+
"\u001b[K |████████████████████████████████| 227 kB 46.0 MB/s eta 0:00:01\n",
|
60 |
+
"\u001b[?25hCollecting protobuf<4,>=3.18.0\n",
|
61 |
+
" Downloading https://mirrors.aliyun.com/pypi/packages/9f/1a/6848ed1669a6c70bf947d25d64ce6dcc65ccec06e917072df516944fa17e/protobuf-3.20.3-cp38-cp38-macosx_10_9_x86_64.whl (982 kB)\n",
|
62 |
+
"\u001b[K |████████████████████████████████| 982 kB 260 kB/s eta 0:00:01\n",
|
63 |
+
"\u001b[?25hRequirement already satisfied: CFFI>=1.0 in /Users/luis/miniconda3/lib/python3.8/site-packages (from sounddevice>=0.4.4->tflite-support) (1.14.3)\n",
|
64 |
+
"Requirement already satisfied: six in /Users/luis/miniconda3/lib/python3.8/site-packages (from absl-py>=0.7.0->tflite-support) (1.15.0)\n",
|
65 |
+
"Requirement already satisfied: pycparser in /Users/luis/miniconda3/lib/python3.8/site-packages (from CFFI>=1.0->sounddevice>=0.4.4->tflite-support) (2.20)\n",
|
66 |
+
"Installing collected packages: sounddevice, numpy, flatbuffers, pybind11, protobuf, tflite-support\n",
|
67 |
+
" Attempting uninstall: numpy\n",
|
68 |
+
" Found existing installation: numpy 1.19.5\n",
|
69 |
+
" Uninstalling numpy-1.19.5:\n",
|
70 |
+
" Successfully uninstalled numpy-1.19.5\n",
|
71 |
+
" Attempting uninstall: flatbuffers\n",
|
72 |
+
" Found existing installation: flatbuffers 1.12\n",
|
73 |
+
" Uninstalling flatbuffers-1.12:\n",
|
74 |
+
" Successfully uninstalled flatbuffers-1.12\n",
|
75 |
+
" Attempting uninstall: protobuf\n",
|
76 |
+
" Found existing installation: protobuf 3.17.3\n",
|
77 |
+
" Uninstalling protobuf-3.17.3:\n",
|
78 |
+
" Successfully uninstalled protobuf-3.17.3\n",
|
79 |
+
"\u001b[31mERROR: After October 2020 you may experience errors when installing or updating packages. This is because pip will change the way that it resolves dependency conflicts.\n",
|
80 |
+
"\n",
|
81 |
+
"We recommend you use --use-feature=2020-resolver to test your packages with the new resolver before it becomes the default.\n",
|
82 |
+
"\n",
|
83 |
+
"tensorflow 2.5.0 requires flatbuffers~=1.12.0, but you'll have flatbuffers 23.5.26 which is incompatible.\n",
|
84 |
+
"tensorflow 2.5.0 requires numpy~=1.19.2, but you'll have numpy 1.24.4 which is incompatible.\n",
|
85 |
+
"pytorch-lightning 2.0.6 requires tqdm>=4.57.0, but you'll have tqdm 4.51.0 which is incompatible.\n",
|
86 |
+
"pytorch-lightning 2.0.6 requires typing-extensions>=4.0.0, but you'll have typing-extensions 3.7.4.3 which is incompatible.\n",
|
87 |
+
"numba 0.56.0 requires numpy<1.23,>=1.18, but you'll have numpy 1.24.4 which is incompatible.\n",
|
88 |
+
"lightning 2.0.6 requires tqdm<6.0,>=4.57.0, but you'll have tqdm 4.51.0 which is incompatible.\n",
|
89 |
+
"lightning 2.0.6 requires typing-extensions<6.0,>=4.0.0, but you'll have typing-extensions 3.7.4.3 which is incompatible.\u001b[0m\n",
|
90 |
+
"Successfully installed flatbuffers-23.5.26 numpy-1.24.4 protobuf-3.20.3 pybind11-2.11.1 sounddevice-0.4.6 tflite-support-0.4.3\n"
|
91 |
+
]
|
92 |
+
}
|
93 |
+
],
|
94 |
+
"source": [
|
95 |
+
"!pip install -i https://mirrors.aliyun.com/pypi/simple tflite-support"
|
96 |
+
]
|
97 |
+
},
|
98 |
+
{
|
99 |
+
"cell_type": "code",
|
100 |
+
"execution_count": 25,
|
101 |
+
"metadata": {
|
102 |
+
"colab": {
|
103 |
+
"base_uri": "https://localhost:8080/",
|
104 |
+
"height": 245.0
|
105 |
+
},
|
106 |
+
"id": "Kl6laUiQRBeT",
|
107 |
+
"outputId": "68130993-d7ad-46cf-a189-c67e1843b62d"
|
108 |
+
},
|
109 |
+
"outputs": [
|
110 |
+
{
|
111 |
+
"name": "stderr",
|
112 |
+
"output_type": "stream",
|
113 |
+
"text": [
|
114 |
+
"/Users/luis/miniconda3/lib/python3.8/site-packages/tensorflow/python/framework/dtypes.py:511: FutureWarning: In the future `np.object` will be defined as the corresponding NumPy scalar.\n",
|
115 |
+
" np.object,\n"
|
116 |
+
]
|
117 |
+
},
|
118 |
+
{
|
119 |
+
"ename": "AttributeError",
|
120 |
+
"evalue": "module 'numpy' has no attribute 'object'.\n`np.object` was a deprecated alias for the builtin `object`. To avoid this error in existing code, use `object` by itself. Doing this will not modify any behavior and is safe. \nThe aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:\n https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations",
|
121 |
+
"traceback": [
|
122 |
+
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
123 |
+
"\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)",
|
124 |
+
"\u001b[0;32m/var/folders/8c/clfh0x3s6wg77ms0cdgcbt1w0000gn/T/ipykernel_64159/35834893.py\u001b[0m in \u001b[0;36m<cell line: 2>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0;31m# Imports\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0mtflite_support\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mtask\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0maudio\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 3\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mtflite_support\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mtask\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mcore\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mtflite_support\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mtask\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mprocessor\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
|
125 |
+
"\u001b[0;32m~/miniconda3/lib/python3.8/site-packages/tflite_support/__init__.py\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 46\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mtensorflow_lite_support\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmetadata\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mmetadata_schema_py_generated\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 47\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mtensorflow_lite_support\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmetadata\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mschema_py_generated\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 48\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0mtensorflow_lite_support\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmetadata\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpython\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mmetadata\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 49\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mtflite_support\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mmetadata_writers\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 50\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
|
126 |
+
"\u001b[0;32m~/miniconda3/lib/python3.8/site-packages/tensorflow_lite_support/metadata/python/metadata.py\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 35\u001b[0m \u001b[0;31m# support more than local file systems.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 36\u001b[0m \u001b[0;31m# In pip requirements, we doesn't necessarily need tensorflow as a dep.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 37\u001b[0;31m \u001b[0;32mimport\u001b[0m \u001b[0mtensorflow\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0mtf\u001b[0m \u001b[0;31m# pylint: disable=g-import-not-at-top\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 38\u001b[0m \u001b[0m_open_file\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mtf\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mio\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mgfile\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mGFile\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 39\u001b[0m \u001b[0m_exists_file\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mtf\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mio\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mgfile\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mexists\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
|
127 |
+
"\u001b[0;32m~/miniconda3/lib/python3.8/site-packages/tensorflow/__init__.py\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 39\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0msys\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0m_sys\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 40\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 41\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0mtensorflow\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpython\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mtools\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mmodule_util\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0m_module_util\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 42\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mtensorflow\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpython\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mutil\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mlazy_loader\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mLazyLoader\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0m_LazyLoader\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 43\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
|
128 |
+
"\u001b[0;32m~/miniconda3/lib/python3.8/site-packages/tensorflow/python/__init__.py\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 44\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 45\u001b[0m \u001b[0;31m# Bring in subpackages.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 46\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0mtensorflow\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpython\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mdata\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 47\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mtensorflow\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpython\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mdistribute\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 48\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mtensorflow\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpython\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mkeras\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
|
129 |
+
"\u001b[0;32m~/miniconda3/lib/python3.8/site-packages/tensorflow/python/data/__init__.py\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 23\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 24\u001b[0m \u001b[0;31m# pylint: disable=unused-import\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 25\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0mtensorflow\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpython\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdata\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mexperimental\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 26\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mtensorflow\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpython\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdata\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mops\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdataset_ops\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mAUTOTUNE\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 27\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mtensorflow\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpython\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdata\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mops\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdataset_ops\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mDataset\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
|
130 |
+
"\u001b[0;32m~/miniconda3/lib/python3.8/site-packages/tensorflow/python/data/experimental/__init__.py\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 97\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 98\u001b[0m \u001b[0;31m# pylint: disable=unused-import\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 99\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0mtensorflow\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpython\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdata\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mexperimental\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mservice\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 100\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mtensorflow\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpython\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdata\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mexperimental\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mops\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mbatching\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mdense_to_ragged_batch\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 101\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mtensorflow\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpython\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdata\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mexperimental\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mops\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mbatching\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mdense_to_sparse_batch\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
|
131 |
+
"\u001b[0;32m~/miniconda3/lib/python3.8/site-packages/tensorflow/python/data/experimental/service/__init__.py\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 138\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0m__future__\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mprint_function\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 139\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 140\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0mtensorflow\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpython\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdata\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mexperimental\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mops\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdata_service_ops\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mdistribute\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 141\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mtensorflow\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpython\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdata\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mexperimental\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mops\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdata_service_ops\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mfrom_dataset_id\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 142\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mtensorflow\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpython\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdata\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mexperimental\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mops\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdata_service_ops\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mregister_dataset\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
|
132 |
+
"\u001b[0;32m~/miniconda3/lib/python3.8/site-packages/tensorflow/python/data/experimental/ops/data_service_ops.py\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 23\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 24\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mtensorflow\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpython\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mtf2\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 25\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0mtensorflow\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpython\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdata\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mexperimental\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mops\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mcompression_ops\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 26\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mtensorflow\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpython\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdata\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mexperimental\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mops\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdistribute_options\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mAutoShardPolicy\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 27\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mtensorflow\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpython\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdata\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mexperimental\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mops\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdistribute_options\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mExternalStatePolicy\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
|
133 |
+
"\u001b[0;32m~/miniconda3/lib/python3.8/site-packages/tensorflow/python/data/experimental/ops/compression_ops.py\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 18\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0m__future__\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mprint_function\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 19\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 20\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0mtensorflow\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpython\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdata\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mutil\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mstructure\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 21\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mtensorflow\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpython\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mops\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mgen_experimental_dataset_ops\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0mged_ops\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 22\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
|
134 |
+
"\u001b[0;32m~/miniconda3/lib/python3.8/site-packages/tensorflow/python/data/util/structure.py\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 24\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mwrapt\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 25\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 26\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0mtensorflow\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpython\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdata\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mutil\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mnest\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 27\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mtensorflow\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpython\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mframework\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mcomposite_tensor\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 28\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mtensorflow\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpython\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mframework\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mops\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
|
135 |
+
"\u001b[0;32m~/miniconda3/lib/python3.8/site-packages/tensorflow/python/data/util/nest.py\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 38\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0msix\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0m_six\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 39\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 40\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0mtensorflow\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpython\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mframework\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0msparse_tensor\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0m_sparse_tensor\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 41\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mtensorflow\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpython\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mutil\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0m_pywrap_utils\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 42\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mtensorflow\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpython\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mutil\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mnest\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
|
136 |
+
"\u001b[0;32m~/miniconda3/lib/python3.8/site-packages/tensorflow/python/framework/sparse_tensor.py\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 26\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mtensorflow\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpython\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mtf2\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 27\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mtensorflow\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpython\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mframework\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mcomposite_tensor\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 28\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0mtensorflow\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpython\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mframework\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mconstant_op\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 29\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mtensorflow\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpython\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mframework\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mdtypes\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 30\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mtensorflow\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpython\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mframework\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mops\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
|
137 |
+
"\u001b[0;32m~/miniconda3/lib/python3.8/site-packages/tensorflow/python/framework/constant_op.py\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 27\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mtensorflow\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcore\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mframework\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mtypes_pb2\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 28\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mtensorflow\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpython\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0meager\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mcontext\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 29\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0mtensorflow\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpython\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0meager\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mexecute\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 30\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mtensorflow\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpython\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mframework\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mdtypes\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 31\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mtensorflow\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpython\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mframework\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mop_callbacks\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
|
138 |
+
"\u001b[0;32m~/miniconda3/lib/python3.8/site-packages/tensorflow/python/eager/execute.py\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 25\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mtensorflow\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpython\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mpywrap_tfe\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 26\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mtensorflow\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpython\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0meager\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mcore\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 27\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0mtensorflow\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpython\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mframework\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mdtypes\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 28\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mtensorflow\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpython\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mframework\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mops\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 29\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mtensorflow\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpython\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mframework\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mtensor_shape\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
|
139 |
+
"\u001b[0;32m~/miniconda3/lib/python3.8/site-packages/tensorflow/python/framework/dtypes.py\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 509\u001b[0m \u001b[0;31m# strings.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 510\u001b[0m \u001b[0mtypes_pb2\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mDT_STRING\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 511\u001b[0;31m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mobject\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 512\u001b[0m \u001b[0mtypes_pb2\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mDT_COMPLEX64\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 513\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcomplex64\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
|
140 |
+
"\u001b[0;32m~/miniconda3/lib/python3.8/site-packages/numpy/__init__.py\u001b[0m in \u001b[0;36m__getattr__\u001b[0;34m(attr)\u001b[0m\n\u001b[1;32m 303\u001b[0m \u001b[0;31m# the full `numpy.testing` namespace\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 304\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mattr\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0;34m'testing'\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 305\u001b[0;31m \u001b[0;32mimport\u001b[0m \u001b[0mnumpy\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mtesting\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0mtesting\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 306\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mtesting\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 307\u001b[0m \u001b[0;32melif\u001b[0m \u001b[0mattr\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0;34m'Tester'\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
|
141 |
+
"\u001b[0;31mAttributeError\u001b[0m: module 'numpy' has no attribute 'object'.\n`np.object` was a deprecated alias for the builtin `object`. To avoid this error in existing code, use `object` by itself. Doing this will not modify any behavior and is safe. \nThe aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:\n https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations"
|
142 |
+
],
|
143 |
+
"output_type": "error"
|
144 |
+
}
|
145 |
+
],
|
146 |
+
"source": [
|
147 |
+
"# Imports\n",
|
148 |
+
"from tflite_support.task import audio\n",
|
149 |
+
"from tflite_support.task import core\n",
|
150 |
+
"from tflite_support.task import processor\n",
|
151 |
+
"\n",
|
152 |
+
"model_path = 'model_v8.1.tflite'\n",
|
153 |
+
"audio_path = 'res/snore/pro_snore 1f6d0dcf8499f3bc _7b23e49bc4f8d31fac175ac362ce34e76550914d.wav'\n",
|
154 |
+
"\n",
|
155 |
+
"# Initialization\n",
|
156 |
+
"base_options = core.BaseOptions(file_name=model_path)\n",
|
157 |
+
"classification_options = processor.ClassificationOptions(max_results=2)\n",
|
158 |
+
"options = audio.AudioClassifierOptions(base_options=base_options, classification_options=classification_options)\n",
|
159 |
+
"classifier = audio.AudioClassifier.create_from_options(options)\n",
|
160 |
+
"\n",
|
161 |
+
"# Alternatively, you can create an audio classifier in the following manner:\n",
|
162 |
+
"# classifier = audio.AudioClassifier.create_from_file(model_path)\n",
|
163 |
+
"\n",
|
164 |
+
"# Run inference\n",
|
165 |
+
"audio_file = audio.TensorAudio.create_from_wav_file(audio_path, classifier.required_input_buffer_size)\n",
|
166 |
+
"audio_result = classifier.classify(audio_file)"
|
167 |
+
]
|
168 |
+
},
|
169 |
+
{
|
170 |
+
"cell_type": "code",
|
171 |
+
"execution_count": null,
|
172 |
+
"metadata": {},
|
173 |
+
"outputs": [],
|
174 |
+
"source": []
|
175 |
+
}
|
176 |
+
],
|
177 |
+
"metadata": {
|
178 |
+
"colab": {
|
179 |
+
"provenance": []
|
180 |
+
},
|
181 |
+
"kernelspec": {
|
182 |
+
"display_name": "Python 3 (ipykernel)",
|
183 |
+
"language": "python",
|
184 |
+
"name": "python3"
|
185 |
+
},
|
186 |
+
"language_info": {
|
187 |
+
"codemirror_mode": {
|
188 |
+
"name": "ipython",
|
189 |
+
"version": 3
|
190 |
+
},
|
191 |
+
"file_extension": ".py",
|
192 |
+
"mimetype": "text/x-python",
|
193 |
+
"name": "python",
|
194 |
+
"nbconvert_exporter": "python",
|
195 |
+
"pygments_lexer": "ipython3",
|
196 |
+
"version": "3.8.5"
|
197 |
+
}
|
198 |
+
},
|
199 |
+
"nbformat": 4,
|
200 |
+
"nbformat_minor": 1
|
201 |
+
}
|
python/util/__init__.py
ADDED
File without changes
|
python/util/__pycache__/__init__.cpython-38.pyc
ADDED
Binary file (154 Bytes). View file
|
|
python/util/__pycache__/audio_util.cpython-38.pyc
ADDED
Binary file (600 Bytes). View file
|
|
python/util/__pycache__/plt_util.cpython-38.pyc
ADDED
Binary file (2.4 kB). View file
|
|
python/util/__pycache__/str_util.cpython-38.pyc
ADDED
Binary file (414 Bytes). View file
|
|
python/util/__pycache__/tensorflow_util.cpython-38.pyc
ADDED
Binary file (770 Bytes). View file
|
|
python/util/__pycache__/time_util.cpython-38.pyc
ADDED
Binary file (321 Bytes). View file
|
|
python/util/apnea_util.py
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from python.util.time_util import int_to_min_sec
|
2 |
+
|
3 |
+
|
4 |
+
def calc_apnea(idx, top_n, score, name):
|
5 |
+
result = ''
|
6 |
+
|
7 |
+
# print(' calc_apnea, idx, top_n, score, name ', int_to_min_sec(idx), top_n, '%.2f' % score, name)
|
8 |
+
which_sec = idx
|
9 |
+
start_sec = -1
|
10 |
+
|
11 |
+
if name == 'Snoring':
|
12 |
+
result = (' idx, top_n, score, name: ' + int_to_min_sec(idx) + ', ' + str(top_n) + ', ' + (
|
13 |
+
'%.2f' % score) + ', ' + name)
|
14 |
+
|
15 |
+
# if name == 'Snoring':
|
16 |
+
# if start_sec == 0: start_sec = which_sec
|
17 |
+
# else:
|
18 |
+
# if snore_sec == 60: start_sec = 0
|
19 |
+
|
20 |
+
return result
|
python/util/audio_util.py
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import sys
|
2 |
+
# print('argv[1]:' + str(sys.argv[1]))
|
3 |
+
import os
|
4 |
+
from pydub import AudioSegment
|
5 |
+
|
6 |
+
|
7 |
+
def audio_to_wav(wav_uri, out_sample_rate=16000):
|
8 |
+
src = wav_uri
|
9 |
+
dst = wav_uri + ".wav"
|
10 |
+
if os.path.exists(dst): os.remove(dst)
|
11 |
+
|
12 |
+
# convert wav to mp3
|
13 |
+
sound = AudioSegment.from_file(src)
|
14 |
+
sound = sound.set_frame_rate(out_sample_rate)
|
15 |
+
sound.export(dst, format="wav")
|
16 |
+
|
17 |
+
print(' audio_to_wav: ', str(dst))
|
18 |
+
return dst
|
19 |
+
|
20 |
+
# sys.argv
|
21 |
+
# if len(sys.argv) > 2:
|
22 |
+
# res = audio_to_wav(sys.argv[1], int(sys.argv[2]))
|
23 |
+
# else:
|
24 |
+
# print(' usage: python audio_util.py /path/to/audio_file [out_sample_rate] ')
|
python/util/plt_util.py
ADDED
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import librosa.display
|
2 |
+
import matplotlib
|
3 |
+
import matplotlib.pyplot as plt
|
4 |
+
import matplotlib.style as ms
|
5 |
+
from PIL import Image
|
6 |
+
|
7 |
+
import matplotlib.ticker as ticker
|
8 |
+
from librosa.feature import melspectrogram
|
9 |
+
from python.util.time_util import int_to_min_sec
|
10 |
+
|
11 |
+
import librosa
|
12 |
+
import librosa.display
|
13 |
+
import numpy as np
|
14 |
+
from io import BytesIO
|
15 |
+
|
16 |
+
# https://stackoverflow.com/questions/69924881/userwarning-starting-a-matplotlib-gui-outside-of-the-main-thread-will-likely-fa
|
17 |
+
matplotlib.use('agg')
|
18 |
+
ms.use('seaborn-muted')
|
19 |
+
|
20 |
+
|
21 |
+
def update_ticks(x, pos):
|
22 |
+
which_second = (x / 16000)
|
23 |
+
return int_to_min_sec(which_second)
|
24 |
+
|
25 |
+
|
26 |
+
def plt_line(y_points, sample_rate=16000):
|
27 |
+
# plt line
|
28 |
+
fig, ax = plt.subplots()
|
29 |
+
ax.xaxis.set_major_formatter(ticker.FuncFormatter(update_ticks))
|
30 |
+
plt.plot(y_points)
|
31 |
+
|
32 |
+
# plot to image
|
33 |
+
buffer = BytesIO()
|
34 |
+
plt.savefig(buffer, format='png')
|
35 |
+
image = Image.open(buffer)
|
36 |
+
|
37 |
+
return image
|
38 |
+
|
39 |
+
|
40 |
+
# plt mfcc, https://www.cnblogs.com/LXP-Never/p/10918590.html
|
41 |
+
def plt_mfcc(single_channel, sample_rate):
|
42 |
+
mel_spec = melspectrogram(y=single_channel, sr=sample_rate, n_fft=1024, hop_length=512, n_mels=128)
|
43 |
+
log_mel_spec = librosa.power_to_db(mel_spec)
|
44 |
+
plt.figure()
|
45 |
+
librosa.display.specshow(log_mel_spec, sr=sample_rate, x_axis='time', y_axis='mel')
|
46 |
+
plt.colorbar(format='%+2.0f dB') # 右边的色度条
|
47 |
+
plt.title('mfcc waveform')
|
48 |
+
|
49 |
+
# plot to image
|
50 |
+
buffer = BytesIO()
|
51 |
+
plt.savefig(buffer, format='png')
|
52 |
+
image = Image.open(buffer)
|
53 |
+
|
54 |
+
return image
|
55 |
+
|
56 |
+
|
57 |
+
# https://gist.github.com/stevemclaugh/80f192130852353ad53e6d8b6b275983
|
58 |
+
def plt_mfcc2(wav_pathname, sample_rate):
|
59 |
+
y, sr = librosa.load(wav_pathname)
|
60 |
+
# Let's make and display a mel-scaled power (energy-squared) spectrogram
|
61 |
+
S = librosa.feature.melspectrogram(y=y, sr=sample_rate, n_mels=128)
|
62 |
+
|
63 |
+
# Convert to log scale (dB). We'll use the peak power as reference.
|
64 |
+
log_S = librosa.amplitude_to_db(S)
|
65 |
+
|
66 |
+
# Make a new figure
|
67 |
+
plt.figure(figsize=(12, 4))
|
68 |
+
|
69 |
+
# Display the spectrogram on a mel scale
|
70 |
+
# sample rate and hop length parameters are used to render the time axis
|
71 |
+
librosa.display.specshow(log_S, sr=sample_rate, x_axis='time', y_axis='mel')
|
72 |
+
|
73 |
+
# Put a descriptive title on the plot
|
74 |
+
plt.title('mel power spectrogram')
|
75 |
+
|
76 |
+
# draw a color bar
|
77 |
+
plt.colorbar(format='%+02.0f dB')
|
78 |
+
|
79 |
+
# Make the figure layout compact
|
80 |
+
plt.tight_layout()
|
81 |
+
|
82 |
+
S_rot = np.rot90(S, 3)
|
83 |
+
|
84 |
+
# Next, we'll extract the first 13 Mel-frequency cepstral coefficients (MFCCs)
|
85 |
+
mfcc = librosa.feature.mfcc(S=log_S, n_mfcc=13)
|
86 |
+
|
87 |
+
# Padding first and second deltas
|
88 |
+
delta_mfcc = librosa.feature.delta(mfcc)
|
89 |
+
delta2_mfcc = librosa.feature.delta(mfcc, order=2)
|
90 |
+
|
91 |
+
# We'll show each in its own subplot
|
92 |
+
# plt.figure(figsize=(12, 6))
|
93 |
+
plt.figure()
|
94 |
+
|
95 |
+
# plt.subplot(3, 1, 1)
|
96 |
+
# librosa.display.specshow(mfcc)
|
97 |
+
# plt.ylabel('MFCC')
|
98 |
+
# plt.colorbar()
|
99 |
+
|
100 |
+
# plt.subplot(1, 1, 1)
|
101 |
+
# librosa.display.specshow(delta_mfcc)
|
102 |
+
# plt.ylabel('MFCC-$\Delta$')
|
103 |
+
# plt.colorbar()
|
104 |
+
|
105 |
+
plt.subplot()
|
106 |
+
librosa.display.specshow(delta2_mfcc, sr=sample_rate, x_axis='time')
|
107 |
+
plt.ylabel('MFCC-$\Delta^2$')
|
108 |
+
plt.colorbar()
|
109 |
+
|
110 |
+
plt.tight_layout()
|
111 |
+
|
112 |
+
# plot to image
|
113 |
+
buffer = BytesIO()
|
114 |
+
plt.savefig(buffer, format='png')
|
115 |
+
image = Image.open(buffer)
|
116 |
+
|
117 |
+
return image
|
python/util/str_util.py
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
def truncate_str(the_str, the_max):
|
2 |
+
return the_str[:the_max] if len(the_str) > the_max else the_str
|
3 |
+
|
4 |
+
|
5 |
+
def format_float(f):
|
6 |
+
return '%.2f' % f
|
python/util/tensorflow_util.py
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import tensorflow as tf
|
2 |
+
import numpy as np
|
3 |
+
|
4 |
+
|
5 |
+
def predict(model_path, waveform):
|
6 |
+
# Download the model to yamnet.tflite
|
7 |
+
interpreter = tf.lite.Interpreter(model_path)
|
8 |
+
|
9 |
+
input_details = interpreter.get_input_details()
|
10 |
+
waveform_input_index = input_details[0]['index']
|
11 |
+
output_details = interpreter.get_output_details()
|
12 |
+
scores_output_index = output_details[0]['index']
|
13 |
+
# embeddings_output_index = output_details[1]['index']
|
14 |
+
# spectrogram_output_index = output_details[2]['index']
|
15 |
+
|
16 |
+
# Input: 0.975 seconds of silence as mono 16 kHz waveform samples.
|
17 |
+
# waveform = np.zeros(int(round(0.975 * 16000)), dtype=np.float32)
|
18 |
+
waveform2 = waveform[:156000]
|
19 |
+
print(waveform2.shape) # Should print (15600,)
|
20 |
+
|
21 |
+
interpreter.resize_tensor_input(waveform_input_index, [waveform.size], strict=True)
|
22 |
+
interpreter.allocate_tensors()
|
23 |
+
interpreter.set_tensor(waveform_input_index, waveform)
|
24 |
+
interpreter.invoke()
|
25 |
+
scores = interpreter.get_tensor(scores_output_index)
|
26 |
+
# print(' scores, embeddings, spectrogram: ', scores.shape, embeddings.shape, spectrogram.shape) # (N, 521) (N, 1024) (M, 64)
|
27 |
+
|
28 |
+
return scores
|
python/util/time_util.py
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import time
|
2 |
+
|
3 |
+
|
4 |
+
def int_to_min_sec(i):
|
5 |
+
return time.strftime('%M:%S', time.gmtime(i))
|
requirements.txt
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
PIL
|
2 |
+
librosa
|
3 |
+
soundfile
|
4 |
+
matplotlib
|
5 |
+
gradio
|
6 |
+
tensorflow
|
7 |
+
tensorflow_hub
|
8 |
+
numpy
|
9 |
+
scipy
|
10 |
+
pydub
|
res/lite-model_yamnet_classification_tflite_1.tflite
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:10c95ea3eb9a7bb4cb8bddf6feb023250381008177ac162ce169694d05c317de
|
3 |
+
size 4126810
|
res/yamnet_class_map.csv
ADDED
@@ -0,0 +1,522 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
index,mid,display_name
|
2 |
+
0,/m/09x0r,Speech
|
3 |
+
1,/m/0ytgt,"Child speech, kid speaking"
|
4 |
+
2,/m/01h8n0,Conversation
|
5 |
+
3,/m/02qldy,"Narration, monologue"
|
6 |
+
4,/m/0261r1,Babbling
|
7 |
+
5,/m/0brhx,Speech synthesizer
|
8 |
+
6,/m/07p6fty,Shout
|
9 |
+
7,/m/07q4ntr,Bellow
|
10 |
+
8,/m/07rwj3x,Whoop
|
11 |
+
9,/m/07sr1lc,Yell
|
12 |
+
10,/t/dd00135,Children shouting
|
13 |
+
11,/m/03qc9zr,Screaming
|
14 |
+
12,/m/02rtxlg,Whispering
|
15 |
+
13,/m/01j3sz,Laughter
|
16 |
+
14,/t/dd00001,Baby laughter
|
17 |
+
15,/m/07r660_,Giggle
|
18 |
+
16,/m/07s04w4,Snicker
|
19 |
+
17,/m/07sq110,Belly laugh
|
20 |
+
18,/m/07rgt08,"Chuckle, chortle"
|
21 |
+
19,/m/0463cq4,"Crying, sobbing"
|
22 |
+
20,/t/dd00002,"Baby cry, infant cry"
|
23 |
+
21,/m/07qz6j3,Whimper
|
24 |
+
22,/m/07qw_06,"Wail, moan"
|
25 |
+
23,/m/07plz5l,Sigh
|
26 |
+
24,/m/015lz1,Singing
|
27 |
+
25,/m/0l14jd,Choir
|
28 |
+
26,/m/01swy6,Yodeling
|
29 |
+
27,/m/02bk07,Chant
|
30 |
+
28,/m/01c194,Mantra
|
31 |
+
29,/t/dd00005,Child singing
|
32 |
+
30,/t/dd00006,Synthetic singing
|
33 |
+
31,/m/06bxc,Rapping
|
34 |
+
32,/m/02fxyj,Humming
|
35 |
+
33,/m/07s2xch,Groan
|
36 |
+
34,/m/07r4k75,Grunt
|
37 |
+
35,/m/01w250,Whistling
|
38 |
+
36,/m/0lyf6,Breathing
|
39 |
+
37,/m/07mzm6,Wheeze
|
40 |
+
38,/m/01d3sd,Snoring
|
41 |
+
39,/m/07s0dtb,Gasp
|
42 |
+
40,/m/07pyy8b,Pant
|
43 |
+
41,/m/07q0yl5,Snort
|
44 |
+
42,/m/01b_21,Cough
|
45 |
+
43,/m/0dl9sf8,Throat clearing
|
46 |
+
44,/m/01hsr_,Sneeze
|
47 |
+
45,/m/07ppn3j,Sniff
|
48 |
+
46,/m/06h7j,Run
|
49 |
+
47,/m/07qv_x_,Shuffle
|
50 |
+
48,/m/07pbtc8,"Walk, footsteps"
|
51 |
+
49,/m/03cczk,"Chewing, mastication"
|
52 |
+
50,/m/07pdhp0,Biting
|
53 |
+
51,/m/0939n_,Gargling
|
54 |
+
52,/m/01g90h,Stomach rumble
|
55 |
+
53,/m/03q5_w,"Burping, eructation"
|
56 |
+
54,/m/02p3nc,Hiccup
|
57 |
+
55,/m/02_nn,Fart
|
58 |
+
56,/m/0k65p,Hands
|
59 |
+
57,/m/025_jnm,Finger snapping
|
60 |
+
58,/m/0l15bq,Clapping
|
61 |
+
59,/m/01jg02,"Heart sounds, heartbeat"
|
62 |
+
60,/m/01jg1z,Heart murmur
|
63 |
+
61,/m/053hz1,Cheering
|
64 |
+
62,/m/028ght,Applause
|
65 |
+
63,/m/07rkbfh,Chatter
|
66 |
+
64,/m/03qtwd,Crowd
|
67 |
+
65,/m/07qfr4h,"Hubbub, speech noise, speech babble"
|
68 |
+
66,/t/dd00013,Children playing
|
69 |
+
67,/m/0jbk,Animal
|
70 |
+
68,/m/068hy,"Domestic animals, pets"
|
71 |
+
69,/m/0bt9lr,Dog
|
72 |
+
70,/m/05tny_,Bark
|
73 |
+
71,/m/07r_k2n,Yip
|
74 |
+
72,/m/07qf0zm,Howl
|
75 |
+
73,/m/07rc7d9,Bow-wow
|
76 |
+
74,/m/0ghcn6,Growling
|
77 |
+
75,/t/dd00136,Whimper (dog)
|
78 |
+
76,/m/01yrx,Cat
|
79 |
+
77,/m/02yds9,Purr
|
80 |
+
78,/m/07qrkrw,Meow
|
81 |
+
79,/m/07rjwbb,Hiss
|
82 |
+
80,/m/07r81j2,Caterwaul
|
83 |
+
81,/m/0ch8v,"Livestock, farm animals, working animals"
|
84 |
+
82,/m/03k3r,Horse
|
85 |
+
83,/m/07rv9rh,Clip-clop
|
86 |
+
84,/m/07q5rw0,"Neigh, whinny"
|
87 |
+
85,/m/01xq0k1,"Cattle, bovinae"
|
88 |
+
86,/m/07rpkh9,Moo
|
89 |
+
87,/m/0239kh,Cowbell
|
90 |
+
88,/m/068zj,Pig
|
91 |
+
89,/t/dd00018,Oink
|
92 |
+
90,/m/03fwl,Goat
|
93 |
+
91,/m/07q0h5t,Bleat
|
94 |
+
92,/m/07bgp,Sheep
|
95 |
+
93,/m/025rv6n,Fowl
|
96 |
+
94,/m/09b5t,"Chicken, rooster"
|
97 |
+
95,/m/07st89h,Cluck
|
98 |
+
96,/m/07qn5dc,"Crowing, cock-a-doodle-doo"
|
99 |
+
97,/m/01rd7k,Turkey
|
100 |
+
98,/m/07svc2k,Gobble
|
101 |
+
99,/m/09ddx,Duck
|
102 |
+
100,/m/07qdb04,Quack
|
103 |
+
101,/m/0dbvp,Goose
|
104 |
+
102,/m/07qwf61,Honk
|
105 |
+
103,/m/01280g,Wild animals
|
106 |
+
104,/m/0cdnk,"Roaring cats (lions, tigers)"
|
107 |
+
105,/m/04cvmfc,Roar
|
108 |
+
106,/m/015p6,Bird
|
109 |
+
107,/m/020bb7,"Bird vocalization, bird call, bird song"
|
110 |
+
108,/m/07pggtn,"Chirp, tweet"
|
111 |
+
109,/m/07sx8x_,Squawk
|
112 |
+
110,/m/0h0rv,"Pigeon, dove"
|
113 |
+
111,/m/07r_25d,Coo
|
114 |
+
112,/m/04s8yn,Crow
|
115 |
+
113,/m/07r5c2p,Caw
|
116 |
+
114,/m/09d5_,Owl
|
117 |
+
115,/m/07r_80w,Hoot
|
118 |
+
116,/m/05_wcq,"Bird flight, flapping wings"
|
119 |
+
117,/m/01z5f,"Canidae, dogs, wolves"
|
120 |
+
118,/m/06hps,"Rodents, rats, mice"
|
121 |
+
119,/m/04rmv,Mouse
|
122 |
+
120,/m/07r4gkf,Patter
|
123 |
+
121,/m/03vt0,Insect
|
124 |
+
122,/m/09xqv,Cricket
|
125 |
+
123,/m/09f96,Mosquito
|
126 |
+
124,/m/0h2mp,"Fly, housefly"
|
127 |
+
125,/m/07pjwq1,Buzz
|
128 |
+
126,/m/01h3n,"Bee, wasp, etc."
|
129 |
+
127,/m/09ld4,Frog
|
130 |
+
128,/m/07st88b,Croak
|
131 |
+
129,/m/078jl,Snake
|
132 |
+
130,/m/07qn4z3,Rattle
|
133 |
+
131,/m/032n05,Whale vocalization
|
134 |
+
132,/m/04rlf,Music
|
135 |
+
133,/m/04szw,Musical instrument
|
136 |
+
134,/m/0fx80y,Plucked string instrument
|
137 |
+
135,/m/0342h,Guitar
|
138 |
+
136,/m/02sgy,Electric guitar
|
139 |
+
137,/m/018vs,Bass guitar
|
140 |
+
138,/m/042v_gx,Acoustic guitar
|
141 |
+
139,/m/06w87,"Steel guitar, slide guitar"
|
142 |
+
140,/m/01glhc,Tapping (guitar technique)
|
143 |
+
141,/m/07s0s5r,Strum
|
144 |
+
142,/m/018j2,Banjo
|
145 |
+
143,/m/0jtg0,Sitar
|
146 |
+
144,/m/04rzd,Mandolin
|
147 |
+
145,/m/01bns_,Zither
|
148 |
+
146,/m/07xzm,Ukulele
|
149 |
+
147,/m/05148p4,Keyboard (musical)
|
150 |
+
148,/m/05r5c,Piano
|
151 |
+
149,/m/01s0ps,Electric piano
|
152 |
+
150,/m/013y1f,Organ
|
153 |
+
151,/m/03xq_f,Electronic organ
|
154 |
+
152,/m/03gvt,Hammond organ
|
155 |
+
153,/m/0l14qv,Synthesizer
|
156 |
+
154,/m/01v1d8,Sampler
|
157 |
+
155,/m/03q5t,Harpsichord
|
158 |
+
156,/m/0l14md,Percussion
|
159 |
+
157,/m/02hnl,Drum kit
|
160 |
+
158,/m/0cfdd,Drum machine
|
161 |
+
159,/m/026t6,Drum
|
162 |
+
160,/m/06rvn,Snare drum
|
163 |
+
161,/m/03t3fj,Rimshot
|
164 |
+
162,/m/02k_mr,Drum roll
|
165 |
+
163,/m/0bm02,Bass drum
|
166 |
+
164,/m/011k_j,Timpani
|
167 |
+
165,/m/01p970,Tabla
|
168 |
+
166,/m/01qbl,Cymbal
|
169 |
+
167,/m/03qtq,Hi-hat
|
170 |
+
168,/m/01sm1g,Wood block
|
171 |
+
169,/m/07brj,Tambourine
|
172 |
+
170,/m/05r5wn,Rattle (instrument)
|
173 |
+
171,/m/0xzly,Maraca
|
174 |
+
172,/m/0mbct,Gong
|
175 |
+
173,/m/016622,Tubular bells
|
176 |
+
174,/m/0j45pbj,Mallet percussion
|
177 |
+
175,/m/0dwsp,"Marimba, xylophone"
|
178 |
+
176,/m/0dwtp,Glockenspiel
|
179 |
+
177,/m/0dwt5,Vibraphone
|
180 |
+
178,/m/0l156b,Steelpan
|
181 |
+
179,/m/05pd6,Orchestra
|
182 |
+
180,/m/01kcd,Brass instrument
|
183 |
+
181,/m/0319l,French horn
|
184 |
+
182,/m/07gql,Trumpet
|
185 |
+
183,/m/07c6l,Trombone
|
186 |
+
184,/m/0l14_3,Bowed string instrument
|
187 |
+
185,/m/02qmj0d,String section
|
188 |
+
186,/m/07y_7,"Violin, fiddle"
|
189 |
+
187,/m/0d8_n,Pizzicato
|
190 |
+
188,/m/01xqw,Cello
|
191 |
+
189,/m/02fsn,Double bass
|
192 |
+
190,/m/085jw,"Wind instrument, woodwind instrument"
|
193 |
+
191,/m/0l14j_,Flute
|
194 |
+
192,/m/06ncr,Saxophone
|
195 |
+
193,/m/01wy6,Clarinet
|
196 |
+
194,/m/03m5k,Harp
|
197 |
+
195,/m/0395lw,Bell
|
198 |
+
196,/m/03w41f,Church bell
|
199 |
+
197,/m/027m70_,Jingle bell
|
200 |
+
198,/m/0gy1t2s,Bicycle bell
|
201 |
+
199,/m/07n_g,Tuning fork
|
202 |
+
200,/m/0f8s22,Chime
|
203 |
+
201,/m/026fgl,Wind chime
|
204 |
+
202,/m/0150b9,Change ringing (campanology)
|
205 |
+
203,/m/03qjg,Harmonica
|
206 |
+
204,/m/0mkg,Accordion
|
207 |
+
205,/m/0192l,Bagpipes
|
208 |
+
206,/m/02bxd,Didgeridoo
|
209 |
+
207,/m/0l14l2,Shofar
|
210 |
+
208,/m/07kc_,Theremin
|
211 |
+
209,/m/0l14t7,Singing bowl
|
212 |
+
210,/m/01hgjl,Scratching (performance technique)
|
213 |
+
211,/m/064t9,Pop music
|
214 |
+
212,/m/0glt670,Hip hop music
|
215 |
+
213,/m/02cz_7,Beatboxing
|
216 |
+
214,/m/06by7,Rock music
|
217 |
+
215,/m/03lty,Heavy metal
|
218 |
+
216,/m/05r6t,Punk rock
|
219 |
+
217,/m/0dls3,Grunge
|
220 |
+
218,/m/0dl5d,Progressive rock
|
221 |
+
219,/m/07sbbz2,Rock and roll
|
222 |
+
220,/m/05w3f,Psychedelic rock
|
223 |
+
221,/m/06j6l,Rhythm and blues
|
224 |
+
222,/m/0gywn,Soul music
|
225 |
+
223,/m/06cqb,Reggae
|
226 |
+
224,/m/01lyv,Country
|
227 |
+
225,/m/015y_n,Swing music
|
228 |
+
226,/m/0gg8l,Bluegrass
|
229 |
+
227,/m/02x8m,Funk
|
230 |
+
228,/m/02w4v,Folk music
|
231 |
+
229,/m/06j64v,Middle Eastern music
|
232 |
+
230,/m/03_d0,Jazz
|
233 |
+
231,/m/026z9,Disco
|
234 |
+
232,/m/0ggq0m,Classical music
|
235 |
+
233,/m/05lls,Opera
|
236 |
+
234,/m/02lkt,Electronic music
|
237 |
+
235,/m/03mb9,House music
|
238 |
+
236,/m/07gxw,Techno
|
239 |
+
237,/m/07s72n,Dubstep
|
240 |
+
238,/m/0283d,Drum and bass
|
241 |
+
239,/m/0m0jc,Electronica
|
242 |
+
240,/m/08cyft,Electronic dance music
|
243 |
+
241,/m/0fd3y,Ambient music
|
244 |
+
242,/m/07lnk,Trance music
|
245 |
+
243,/m/0g293,Music of Latin America
|
246 |
+
244,/m/0ln16,Salsa music
|
247 |
+
245,/m/0326g,Flamenco
|
248 |
+
246,/m/0155w,Blues
|
249 |
+
247,/m/05fw6t,Music for children
|
250 |
+
248,/m/02v2lh,New-age music
|
251 |
+
249,/m/0y4f8,Vocal music
|
252 |
+
250,/m/0z9c,A capella
|
253 |
+
251,/m/0164x2,Music of Africa
|
254 |
+
252,/m/0145m,Afrobeat
|
255 |
+
253,/m/02mscn,Christian music
|
256 |
+
254,/m/016cjb,Gospel music
|
257 |
+
255,/m/028sqc,Music of Asia
|
258 |
+
256,/m/015vgc,Carnatic music
|
259 |
+
257,/m/0dq0md,Music of Bollywood
|
260 |
+
258,/m/06rqw,Ska
|
261 |
+
259,/m/02p0sh1,Traditional music
|
262 |
+
260,/m/05rwpb,Independent music
|
263 |
+
261,/m/074ft,Song
|
264 |
+
262,/m/025td0t,Background music
|
265 |
+
263,/m/02cjck,Theme music
|
266 |
+
264,/m/03r5q_,Jingle (music)
|
267 |
+
265,/m/0l14gg,Soundtrack music
|
268 |
+
266,/m/07pkxdp,Lullaby
|
269 |
+
267,/m/01z7dr,Video game music
|
270 |
+
268,/m/0140xf,Christmas music
|
271 |
+
269,/m/0ggx5q,Dance music
|
272 |
+
270,/m/04wptg,Wedding music
|
273 |
+
271,/t/dd00031,Happy music
|
274 |
+
272,/t/dd00033,Sad music
|
275 |
+
273,/t/dd00034,Tender music
|
276 |
+
274,/t/dd00035,Exciting music
|
277 |
+
275,/t/dd00036,Angry music
|
278 |
+
276,/t/dd00037,Scary music
|
279 |
+
277,/m/03m9d0z,Wind
|
280 |
+
278,/m/09t49,Rustling leaves
|
281 |
+
279,/t/dd00092,Wind noise (microphone)
|
282 |
+
280,/m/0jb2l,Thunderstorm
|
283 |
+
281,/m/0ngt1,Thunder
|
284 |
+
282,/m/0838f,Water
|
285 |
+
283,/m/06mb1,Rain
|
286 |
+
284,/m/07r10fb,Raindrop
|
287 |
+
285,/t/dd00038,Rain on surface
|
288 |
+
286,/m/0j6m2,Stream
|
289 |
+
287,/m/0j2kx,Waterfall
|
290 |
+
288,/m/05kq4,Ocean
|
291 |
+
289,/m/034srq,"Waves, surf"
|
292 |
+
290,/m/06wzb,Steam
|
293 |
+
291,/m/07swgks,Gurgling
|
294 |
+
292,/m/02_41,Fire
|
295 |
+
293,/m/07pzfmf,Crackle
|
296 |
+
294,/m/07yv9,Vehicle
|
297 |
+
295,/m/019jd,"Boat, Water vehicle"
|
298 |
+
296,/m/0hsrw,"Sailboat, sailing ship"
|
299 |
+
297,/m/056ks2,"Rowboat, canoe, kayak"
|
300 |
+
298,/m/02rlv9,"Motorboat, speedboat"
|
301 |
+
299,/m/06q74,Ship
|
302 |
+
300,/m/012f08,Motor vehicle (road)
|
303 |
+
301,/m/0k4j,Car
|
304 |
+
302,/m/0912c9,"Vehicle horn, car horn, honking"
|
305 |
+
303,/m/07qv_d5,Toot
|
306 |
+
304,/m/02mfyn,Car alarm
|
307 |
+
305,/m/04gxbd,"Power windows, electric windows"
|
308 |
+
306,/m/07rknqz,Skidding
|
309 |
+
307,/m/0h9mv,Tire squeal
|
310 |
+
308,/t/dd00134,Car passing by
|
311 |
+
309,/m/0ltv,"Race car, auto racing"
|
312 |
+
310,/m/07r04,Truck
|
313 |
+
311,/m/0gvgw0,Air brake
|
314 |
+
312,/m/05x_td,"Air horn, truck horn"
|
315 |
+
313,/m/02rhddq,Reversing beeps
|
316 |
+
314,/m/03cl9h,"Ice cream truck, ice cream van"
|
317 |
+
315,/m/01bjv,Bus
|
318 |
+
316,/m/03j1ly,Emergency vehicle
|
319 |
+
317,/m/04qvtq,Police car (siren)
|
320 |
+
318,/m/012n7d,Ambulance (siren)
|
321 |
+
319,/m/012ndj,"Fire engine, fire truck (siren)"
|
322 |
+
320,/m/04_sv,Motorcycle
|
323 |
+
321,/m/0btp2,"Traffic noise, roadway noise"
|
324 |
+
322,/m/06d_3,Rail transport
|
325 |
+
323,/m/07jdr,Train
|
326 |
+
324,/m/04zmvq,Train whistle
|
327 |
+
325,/m/0284vy3,Train horn
|
328 |
+
326,/m/01g50p,"Railroad car, train wagon"
|
329 |
+
327,/t/dd00048,Train wheels squealing
|
330 |
+
328,/m/0195fx,"Subway, metro, underground"
|
331 |
+
329,/m/0k5j,Aircraft
|
332 |
+
330,/m/014yck,Aircraft engine
|
333 |
+
331,/m/04229,Jet engine
|
334 |
+
332,/m/02l6bg,"Propeller, airscrew"
|
335 |
+
333,/m/09ct_,Helicopter
|
336 |
+
334,/m/0cmf2,"Fixed-wing aircraft, airplane"
|
337 |
+
335,/m/0199g,Bicycle
|
338 |
+
336,/m/06_fw,Skateboard
|
339 |
+
337,/m/02mk9,Engine
|
340 |
+
338,/t/dd00065,Light engine (high frequency)
|
341 |
+
339,/m/08j51y,"Dental drill, dentist's drill"
|
342 |
+
340,/m/01yg9g,Lawn mower
|
343 |
+
341,/m/01j4z9,Chainsaw
|
344 |
+
342,/t/dd00066,Medium engine (mid frequency)
|
345 |
+
343,/t/dd00067,Heavy engine (low frequency)
|
346 |
+
344,/m/01h82_,Engine knocking
|
347 |
+
345,/t/dd00130,Engine starting
|
348 |
+
346,/m/07pb8fc,Idling
|
349 |
+
347,/m/07q2z82,"Accelerating, revving, vroom"
|
350 |
+
348,/m/02dgv,Door
|
351 |
+
349,/m/03wwcy,Doorbell
|
352 |
+
350,/m/07r67yg,Ding-dong
|
353 |
+
351,/m/02y_763,Sliding door
|
354 |
+
352,/m/07rjzl8,Slam
|
355 |
+
353,/m/07r4wb8,Knock
|
356 |
+
354,/m/07qcpgn,Tap
|
357 |
+
355,/m/07q6cd_,Squeak
|
358 |
+
356,/m/0642b4,Cupboard open or close
|
359 |
+
357,/m/0fqfqc,Drawer open or close
|
360 |
+
358,/m/04brg2,"Dishes, pots, and pans"
|
361 |
+
359,/m/023pjk,"Cutlery, silverware"
|
362 |
+
360,/m/07pn_8q,Chopping (food)
|
363 |
+
361,/m/0dxrf,Frying (food)
|
364 |
+
362,/m/0fx9l,Microwave oven
|
365 |
+
363,/m/02pjr4,Blender
|
366 |
+
364,/m/02jz0l,"Water tap, faucet"
|
367 |
+
365,/m/0130jx,Sink (filling or washing)
|
368 |
+
366,/m/03dnzn,Bathtub (filling or washing)
|
369 |
+
367,/m/03wvsk,Hair dryer
|
370 |
+
368,/m/01jt3m,Toilet flush
|
371 |
+
369,/m/012xff,Toothbrush
|
372 |
+
370,/m/04fgwm,Electric toothbrush
|
373 |
+
371,/m/0d31p,Vacuum cleaner
|
374 |
+
372,/m/01s0vc,Zipper (clothing)
|
375 |
+
373,/m/03v3yw,Keys jangling
|
376 |
+
374,/m/0242l,Coin (dropping)
|
377 |
+
375,/m/01lsmm,Scissors
|
378 |
+
376,/m/02g901,"Electric shaver, electric razor"
|
379 |
+
377,/m/05rj2,Shuffling cards
|
380 |
+
378,/m/0316dw,Typing
|
381 |
+
379,/m/0c2wf,Typewriter
|
382 |
+
380,/m/01m2v,Computer keyboard
|
383 |
+
381,/m/081rb,Writing
|
384 |
+
382,/m/07pp_mv,Alarm
|
385 |
+
383,/m/07cx4,Telephone
|
386 |
+
384,/m/07pp8cl,Telephone bell ringing
|
387 |
+
385,/m/01hnzm,Ringtone
|
388 |
+
386,/m/02c8p,"Telephone dialing, DTMF"
|
389 |
+
387,/m/015jpf,Dial tone
|
390 |
+
388,/m/01z47d,Busy signal
|
391 |
+
389,/m/046dlr,Alarm clock
|
392 |
+
390,/m/03kmc9,Siren
|
393 |
+
391,/m/0dgbq,Civil defense siren
|
394 |
+
392,/m/030rvx,Buzzer
|
395 |
+
393,/m/01y3hg,"Smoke detector, smoke alarm"
|
396 |
+
394,/m/0c3f7m,Fire alarm
|
397 |
+
395,/m/04fq5q,Foghorn
|
398 |
+
396,/m/0l156k,Whistle
|
399 |
+
397,/m/06hck5,Steam whistle
|
400 |
+
398,/t/dd00077,Mechanisms
|
401 |
+
399,/m/02bm9n,"Ratchet, pawl"
|
402 |
+
400,/m/01x3z,Clock
|
403 |
+
401,/m/07qjznt,Tick
|
404 |
+
402,/m/07qjznl,Tick-tock
|
405 |
+
403,/m/0l7xg,Gears
|
406 |
+
404,/m/05zc1,Pulleys
|
407 |
+
405,/m/0llzx,Sewing machine
|
408 |
+
406,/m/02x984l,Mechanical fan
|
409 |
+
407,/m/025wky1,Air conditioning
|
410 |
+
408,/m/024dl,Cash register
|
411 |
+
409,/m/01m4t,Printer
|
412 |
+
410,/m/0dv5r,Camera
|
413 |
+
411,/m/07bjf,Single-lens reflex camera
|
414 |
+
412,/m/07k1x,Tools
|
415 |
+
413,/m/03l9g,Hammer
|
416 |
+
414,/m/03p19w,Jackhammer
|
417 |
+
415,/m/01b82r,Sawing
|
418 |
+
416,/m/02p01q,Filing (rasp)
|
419 |
+
417,/m/023vsd,Sanding
|
420 |
+
418,/m/0_ksk,Power tool
|
421 |
+
419,/m/01d380,Drill
|
422 |
+
420,/m/014zdl,Explosion
|
423 |
+
421,/m/032s66,"Gunshot, gunfire"
|
424 |
+
422,/m/04zjc,Machine gun
|
425 |
+
423,/m/02z32qm,Fusillade
|
426 |
+
424,/m/0_1c,Artillery fire
|
427 |
+
425,/m/073cg4,Cap gun
|
428 |
+
426,/m/0g6b5,Fireworks
|
429 |
+
427,/g/122z_qxw,Firecracker
|
430 |
+
428,/m/07qsvvw,"Burst, pop"
|
431 |
+
429,/m/07pxg6y,Eruption
|
432 |
+
430,/m/07qqyl4,Boom
|
433 |
+
431,/m/083vt,Wood
|
434 |
+
432,/m/07pczhz,Chop
|
435 |
+
433,/m/07pl1bw,Splinter
|
436 |
+
434,/m/07qs1cx,Crack
|
437 |
+
435,/m/039jq,Glass
|
438 |
+
436,/m/07q7njn,"Chink, clink"
|
439 |
+
437,/m/07rn7sz,Shatter
|
440 |
+
438,/m/04k94,Liquid
|
441 |
+
439,/m/07rrlb6,"Splash, splatter"
|
442 |
+
440,/m/07p6mqd,Slosh
|
443 |
+
441,/m/07qlwh6,Squish
|
444 |
+
442,/m/07r5v4s,Drip
|
445 |
+
443,/m/07prgkl,Pour
|
446 |
+
444,/m/07pqc89,"Trickle, dribble"
|
447 |
+
445,/t/dd00088,Gush
|
448 |
+
446,/m/07p7b8y,Fill (with liquid)
|
449 |
+
447,/m/07qlf79,Spray
|
450 |
+
448,/m/07ptzwd,Pump (liquid)
|
451 |
+
449,/m/07ptfmf,Stir
|
452 |
+
450,/m/0dv3j,Boiling
|
453 |
+
451,/m/0790c,Sonar
|
454 |
+
452,/m/0dl83,Arrow
|
455 |
+
453,/m/07rqsjt,"Whoosh, swoosh, swish"
|
456 |
+
454,/m/07qnq_y,"Thump, thud"
|
457 |
+
455,/m/07rrh0c,Thunk
|
458 |
+
456,/m/0b_fwt,Electronic tuner
|
459 |
+
457,/m/02rr_,Effects unit
|
460 |
+
458,/m/07m2kt,Chorus effect
|
461 |
+
459,/m/018w8,Basketball bounce
|
462 |
+
460,/m/07pws3f,Bang
|
463 |
+
461,/m/07ryjzk,"Slap, smack"
|
464 |
+
462,/m/07rdhzs,"Whack, thwack"
|
465 |
+
463,/m/07pjjrj,"Smash, crash"
|
466 |
+
464,/m/07pc8lb,Breaking
|
467 |
+
465,/m/07pqn27,Bouncing
|
468 |
+
466,/m/07rbp7_,Whip
|
469 |
+
467,/m/07pyf11,Flap
|
470 |
+
468,/m/07qb_dv,Scratch
|
471 |
+
469,/m/07qv4k0,Scrape
|
472 |
+
470,/m/07pdjhy,Rub
|
473 |
+
471,/m/07s8j8t,Roll
|
474 |
+
472,/m/07plct2,Crushing
|
475 |
+
473,/t/dd00112,"Crumpling, crinkling"
|
476 |
+
474,/m/07qcx4z,Tearing
|
477 |
+
475,/m/02fs_r,"Beep, bleep"
|
478 |
+
476,/m/07qwdck,Ping
|
479 |
+
477,/m/07phxs1,Ding
|
480 |
+
478,/m/07rv4dm,Clang
|
481 |
+
479,/m/07s02z0,Squeal
|
482 |
+
480,/m/07qh7jl,Creak
|
483 |
+
481,/m/07qwyj0,Rustle
|
484 |
+
482,/m/07s34ls,Whir
|
485 |
+
483,/m/07qmpdm,Clatter
|
486 |
+
484,/m/07p9k1k,Sizzle
|
487 |
+
485,/m/07qc9xj,Clicking
|
488 |
+
486,/m/07rwm0c,Clickety-clack
|
489 |
+
487,/m/07phhsh,Rumble
|
490 |
+
488,/m/07qyrcz,Plop
|
491 |
+
489,/m/07qfgpx,"Jingle, tinkle"
|
492 |
+
490,/m/07rcgpl,Hum
|
493 |
+
491,/m/07p78v5,Zing
|
494 |
+
492,/t/dd00121,Boing
|
495 |
+
493,/m/07s12q4,Crunch
|
496 |
+
494,/m/028v0c,Silence
|
497 |
+
495,/m/01v_m0,Sine wave
|
498 |
+
496,/m/0b9m1,Harmonic
|
499 |
+
497,/m/0hdsk,Chirp tone
|
500 |
+
498,/m/0c1dj,Sound effect
|
501 |
+
499,/m/07pt_g0,Pulse
|
502 |
+
500,/t/dd00125,"Inside, small room"
|
503 |
+
501,/t/dd00126,"Inside, large room or hall"
|
504 |
+
502,/t/dd00127,"Inside, public space"
|
505 |
+
503,/t/dd00128,"Outside, urban or manmade"
|
506 |
+
504,/t/dd00129,"Outside, rural or natural"
|
507 |
+
505,/m/01b9nn,Reverberation
|
508 |
+
506,/m/01jnbd,Echo
|
509 |
+
507,/m/096m7z,Noise
|
510 |
+
508,/m/06_y0by,Environmental noise
|
511 |
+
509,/m/07rgkc5,Static
|
512 |
+
510,/m/06xkwv,Mains hum
|
513 |
+
511,/m/0g12c5,Distortion
|
514 |
+
512,/m/08p9q4,Sidetone
|
515 |
+
513,/m/07szfh9,Cacophony
|
516 |
+
514,/m/0chx_,White noise
|
517 |
+
515,/m/0cj0r,Pink noise
|
518 |
+
516,/m/07p_0gm,Throbbing
|
519 |
+
517,/m/01jwx6,Vibration
|
520 |
+
518,/m/07c52,Television
|
521 |
+
519,/m/06bz3,Radio
|
522 |
+
520,/m/07hvw1,Field recording
|
test.py
ADDED
@@ -0,0 +1,162 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Imports
|
2 |
+
import csv
|
3 |
+
import sys
|
4 |
+
|
5 |
+
import numpy as np
|
6 |
+
import soundfile
|
7 |
+
import tensorflow as tf
|
8 |
+
|
9 |
+
from python.util.audio_util import audio_to_wav
|
10 |
+
from python.util.plt_util import plt_line, plt_mfcc, plt_mfcc2
|
11 |
+
from python.util.time_util import int_to_min_sec
|
12 |
+
from python.util.str_util import format_float, truncate_str
|
13 |
+
from python.util.tensorflow_util import predict
|
14 |
+
|
15 |
+
# Constants
|
16 |
+
# MODEL_PATH = 'res/lite-model_yamnet_tflite_1.tflite'
|
17 |
+
MODEL_PATH = 'res/lite-model_yamnet_classification_tflite_1.tflite'
|
18 |
+
OUT_SAMPLE_RATE = 16000
|
19 |
+
OUT_PCM = 'PCM_16'
|
20 |
+
CLASS_MAP_FILE = 'res/yamnet_class_map.csv'
|
21 |
+
DEBUG = True
|
22 |
+
SNORING_TOP_N = 7
|
23 |
+
|
24 |
+
|
25 |
+
# Methods
|
26 |
+
def to_ndarray(data):
|
27 |
+
return np.array(data)
|
28 |
+
|
29 |
+
|
30 |
+
def data_to_single_channel(data):
|
31 |
+
result = data
|
32 |
+
|
33 |
+
try:
|
34 |
+
result = data[:, 0]
|
35 |
+
except IndexError:
|
36 |
+
print("An exception occurred")
|
37 |
+
|
38 |
+
return result
|
39 |
+
|
40 |
+
|
41 |
+
def read_single_channel(audio_path):
|
42 |
+
data, sample_rate = soundfile.read(audio_path)
|
43 |
+
print(' sample_rate, audio_path: ', str(sample_rate), str(audio_path))
|
44 |
+
# print(' sample_rate, len, type, shape, shape[1]: ', str(sample_rate), len(data), str(type(data)), str(data.shape), str(data.shape[1]))
|
45 |
+
|
46 |
+
single_channel = data_to_single_channel(data)
|
47 |
+
single_channel_seconds = len(single_channel) / OUT_SAMPLE_RATE
|
48 |
+
# print(' single_channel, shape: ', str(single_channel), str(single_channel.shape))
|
49 |
+
# print(' len, seconds: ', str(len(single_channel)), str(single_channel_seconds))
|
50 |
+
|
51 |
+
return single_channel, sample_rate
|
52 |
+
|
53 |
+
|
54 |
+
def class_names_from_csv(class_map_csv):
|
55 |
+
"""Read the class name definition file and return a list of strings."""
|
56 |
+
if tf.is_tensor(class_map_csv):
|
57 |
+
class_map_csv = class_map_csv.numpy()
|
58 |
+
with open(class_map_csv) as csv_file:
|
59 |
+
reader = csv.reader(csv_file)
|
60 |
+
next(reader) # Skip header
|
61 |
+
return np.array([display_name for (_, _, display_name) in reader])
|
62 |
+
|
63 |
+
|
64 |
+
def scores_to_index(scores, order):
|
65 |
+
means = scores.mean(axis=0)
|
66 |
+
return np.argsort(means, axis=0)[order]
|
67 |
+
|
68 |
+
|
69 |
+
def predict_waveform(idx, waveform):
|
70 |
+
# Download the YAMNet class map (see main YAMNet model docs) to yamnet_class_map.csv
|
71 |
+
# See YAMNet TF2 usage sample for class_names_from_csv() definition.
|
72 |
+
scores = predict(MODEL_PATH, waveform)
|
73 |
+
class_names = class_names_from_csv(CLASS_MAP_FILE)
|
74 |
+
|
75 |
+
top_n = SNORING_TOP_N
|
76 |
+
top_n_res = ''
|
77 |
+
snoring_score = 0.0
|
78 |
+
for n in range(1, top_n):
|
79 |
+
index = scores_to_index(scores, -n)
|
80 |
+
means = scores.mean(axis=0)
|
81 |
+
score = means[index]
|
82 |
+
name = class_names[index]
|
83 |
+
|
84 |
+
if name == 'Snoring':
|
85 |
+
snoring_score = score
|
86 |
+
top_n_res += ' ' + format_float(score) + ' [' + truncate_str(name, 4) + '], '
|
87 |
+
|
88 |
+
snoring_tail = ('打鼾, ' + format_float(snoring_score)) if snoring_score > 0 else ''
|
89 |
+
result = top_n_res + snoring_tail + '\n'
|
90 |
+
if DEBUG: print(top_n_res)
|
91 |
+
|
92 |
+
return result, snoring_score
|
93 |
+
|
94 |
+
|
95 |
+
def to_float32(data):
|
96 |
+
return np.float32(data)
|
97 |
+
|
98 |
+
|
99 |
+
def predict_float32(idx, data):
|
100 |
+
return predict_waveform(idx, to_float32(data))
|
101 |
+
|
102 |
+
|
103 |
+
def split_given_size(arr, size):
|
104 |
+
return np.split(arr, np.arange(size, len(arr), size))
|
105 |
+
|
106 |
+
|
107 |
+
def predict_uri(mp3_uri):
|
108 |
+
result = ''
|
109 |
+
# result = ' mp3_uri: '
|
110 |
+
# result += mp3_uri + '\n'
|
111 |
+
|
112 |
+
mp3_input = mp3_uri
|
113 |
+
wav_input = audio_to_wav(mp3_input) if not mp3_input.endswith('.mp3') == True else mp3_input
|
114 |
+
predict_seconds = int(str(sys.argv[2])) if len(sys.argv) > 2 else 1
|
115 |
+
|
116 |
+
predict_samples = 15600 #OUT_SAMPLE_RATE * predict_seconds
|
117 |
+
single_channel, sc_sample_rate = read_single_channel(wav_input)
|
118 |
+
splits = split_given_size(single_channel, predict_samples)
|
119 |
+
result += ' sc_sample_rate: ' + str(sc_sample_rate) + '\n'
|
120 |
+
|
121 |
+
second_total = len(splits) * predict_seconds
|
122 |
+
result += (' second_total: ' + int_to_min_sec(second_total) + ', \n')
|
123 |
+
result += '\n'
|
124 |
+
snoring_scores = []
|
125 |
+
|
126 |
+
for idx in range(len(splits)):
|
127 |
+
split = splits[idx]
|
128 |
+
second_start = idx * predict_seconds
|
129 |
+
result += (int_to_min_sec(second_start) + ', ')
|
130 |
+
if len(split) == predict_samples:
|
131 |
+
print_result, snoring_score = predict_float32(idx, split)
|
132 |
+
result += print_result
|
133 |
+
snoring_scores.append(snoring_score)
|
134 |
+
|
135 |
+
# plt waveform
|
136 |
+
waveform_line = plt_line(single_channel)
|
137 |
+
# plt mfcc
|
138 |
+
mfcc_line = plt_mfcc(single_channel, OUT_SAMPLE_RATE)
|
139 |
+
# plt mfcc2
|
140 |
+
mfcc2_line = plt_mfcc2(wav_input, OUT_SAMPLE_RATE)
|
141 |
+
# plt snoring_booleans
|
142 |
+
snoring_booleans = list(map(lambda x: 1 if x > 0 else 0, snoring_scores))
|
143 |
+
# calc snoring frequency
|
144 |
+
snoring_sec = len(list(filter(lambda x: 1 if x > 0 else 0, snoring_scores)))
|
145 |
+
snoring_frequency = snoring_sec / second_total
|
146 |
+
apnea_sec = second_total - snoring_sec
|
147 |
+
apnea_frequency = (apnea_sec / 10) / second_total
|
148 |
+
ahi_result = str(
|
149 |
+
'snoring_sec:' + str(snoring_sec) + ', apnea_sec:' + str(apnea_sec) + ', second_total:' + str(second_total)
|
150 |
+
+ ', snoring_frequency:' + format_float(snoring_frequency)
|
151 |
+
+ ', apnea_frequency:' + format_float(apnea_frequency)
|
152 |
+
)
|
153 |
+
|
154 |
+
return waveform_line, mfcc_line, mfcc2_line, str(ahi_result), str(snoring_booleans), str(snoring_scores), str(result)
|
155 |
+
|
156 |
+
|
157 |
+
# sys.argv
|
158 |
+
if len(sys.argv) > 1 and len(sys.argv[1]) > 0:
|
159 |
+
res, plt = predict_uri(sys.argv[1])
|
160 |
+
plt.show()
|
161 |
+
else:
|
162 |
+
print('usage: python test.py /path/to/audio_file [predict_seconds]')
|