├── .DS_Store
├── .gradle
├── 6.1.1
│ ├── executionHistory
│ │ ├── executionHistory.bin
│ │ └── executionHistory.lock
│ ├── fileChanges
│ │ └── last-build.bin
│ ├── fileContent
│ │ └── fileContent.lock
│ ├── fileHashes
│ │ ├── fileHashes.bin
│ │ ├── fileHashes.lock
│ │ └── resourceHashesCache.bin
│ ├── gc.properties
│ └── javaCompile
│ │ ├── classAnalysis.bin
│ │ ├── jarAnalysis.bin
│ │ ├── javaCompile.lock
│ │ └── taskHistory.bin
├── buildOutputCleanup
│ ├── buildOutputCleanup.lock
│ ├── cache.properties
│ └── outputFiles.bin
├── checksums
│ ├── checksums.lock
│ ├── md5-checksums.bin
│ └── sha1-checksums.bin
└── vcs-1
│ └── gc.properties
├── .idea
├── .gitignore
├── .name
├── caches
│ └── build_file_checksums.ser
├── codeStyles
│ ├── Project.xml
│ └── codeStyleConfig.xml
├── gradle.xml
├── jarRepositories.xml
├── libraries
│ ├── Gradle__androidx_activity_activity_1_0_0_aar.xml
│ ├── Gradle__androidx_annotation_annotation_1_1_0_jar.xml
│ ├── Gradle__androidx_appcompat_appcompat_1_1_0_aar.xml
│ ├── Gradle__androidx_appcompat_appcompat_resources_1_1_0_aar.xml
│ ├── Gradle__androidx_arch_core_core_common_2_1_0_jar.xml
│ ├── Gradle__androidx_arch_core_core_runtime_2_0_0_aar.xml
│ ├── Gradle__androidx_collection_collection_1_1_0_jar.xml
│ ├── Gradle__androidx_constraintlayout_constraintlayout_1_1_3_aar.xml
│ ├── Gradle__androidx_constraintlayout_constraintlayout_solver_1_1_3_jar.xml
│ ├── Gradle__androidx_core_core_1_3_0_aar.xml
│ ├── Gradle__androidx_core_core_ktx_1_3_0_aar.xml
│ ├── Gradle__androidx_cursoradapter_cursoradapter_1_0_0_aar.xml
│ ├── Gradle__androidx_customview_customview_1_0_0_aar.xml
│ ├── Gradle__androidx_drawerlayout_drawerlayout_1_0_0_aar.xml
│ ├── Gradle__androidx_fragment_fragment_1_1_0_aar.xml
│ ├── Gradle__androidx_interpolator_interpolator_1_0_0_aar.xml
│ ├── Gradle__androidx_lifecycle_lifecycle_common_2_1_0_jar.xml
│ ├── Gradle__androidx_lifecycle_lifecycle_livedata_2_0_0_aar.xml
│ ├── Gradle__androidx_lifecycle_lifecycle_livedata_core_2_0_0_aar.xml
│ ├── Gradle__androidx_lifecycle_lifecycle_runtime_2_1_0_aar.xml
│ ├── Gradle__androidx_lifecycle_lifecycle_viewmodel_2_1_0_aar.xml
│ ├── Gradle__androidx_loader_loader_1_0_0_aar.xml
│ ├── Gradle__androidx_savedstate_savedstate_1_0_0_aar.xml
│ ├── Gradle__androidx_test_core_1_2_0_aar.xml
│ ├── Gradle__androidx_test_espresso_espresso_core_3_2_0_aar.xml
│ ├── Gradle__androidx_test_espresso_espresso_idling_resource_3_2_0_aar.xml
│ ├── Gradle__androidx_test_ext_junit_1_1_1_aar.xml
│ ├── Gradle__androidx_test_monitor_1_2_0_aar.xml
│ ├── Gradle__androidx_test_runner_1_2_0_aar.xml
│ ├── Gradle__androidx_vectordrawable_vectordrawable_1_1_0_aar.xml
│ ├── Gradle__androidx_vectordrawable_vectordrawable_animated_1_1_0_aar.xml
│ ├── Gradle__androidx_versionedparcelable_versionedparcelable_1_1_0_aar.xml
│ ├── Gradle__androidx_viewpager_viewpager_1_0_0_aar.xml
│ ├── Gradle__com_google_code_findbugs_jsr305_2_0_1_jar.xml
│ ├── Gradle__com_squareup_javawriter_2_1_1_jar.xml
│ ├── Gradle__javax_inject_javax_inject_1_jar.xml
│ ├── Gradle__junit_junit_4_12_jar.xml
│ ├── Gradle__net_sf_kxml_kxml2_2_3_0_jar.xml
│ ├── Gradle__org_hamcrest_hamcrest_core_1_3_jar.xml
│ ├── Gradle__org_hamcrest_hamcrest_integration_1_3_jar.xml
│ ├── Gradle__org_hamcrest_hamcrest_library_1_3_jar.xml
│ ├── Gradle__org_jetbrains_annotations_13_0_jar.xml
│ ├── Gradle__org_jetbrains_kotlin_kotlin_android_extensions_runtime_1_3_72_jar.xml
│ ├── Gradle__org_jetbrains_kotlin_kotlin_stdlib_1_3_72_jar.xml
│ ├── Gradle__org_jetbrains_kotlin_kotlin_stdlib_common_1_3_72_jar.xml
│ ├── Gradle__org_tensorflow_tensorflow_lite_0_0_0_nightly_aar.xml
│ └── Gradle__org_tensorflow_tensorflow_lite_support_0_0_0_nightly_aar.xml
├── misc.xml
├── modules.xml
├── modules
│ ├── MFCCCalculator.iml
│ ├── NoiseClassifier_Android_Tensorflow.iml
│ └── app
│ │ └── app.iml
├── runConfigurations.xml
└── vcs.xml
├── Android_NoiseClassification_Demo.mov
├── Android_NoiseClassification_demo.gif
├── Python_Notebook_Files
├── UrbanSound_200.csv
├── Urban_cnn_model.ipynb
├── Urban_data_preprocess.ipynb
├── model.tflite
├── test_data.csv
├── test_labels.csv
├── train_data.csv
└── train_labels.csv
├── Readme.md
├── SampleAudio
├── 001_children_playing.wav
├── 001_dog_barking.wav
├── 001_street_music.wav
└── 002_dog_barking.wav
├── app
├── .DS_Store
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── .DS_Store
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── tensorflow
│ │ └── android
│ │ └── noiseclassifier
│ │ └── ExampleInstrumentedTest.kt
│ ├── main
│ ├── .DS_Store
│ ├── AndroidManifest.xml
│ ├── assets
│ │ ├── labels.txt
│ │ └── model.tflite
│ ├── java
│ │ ├── .DS_Store
│ │ └── com
│ │ │ ├── .DS_Store
│ │ │ └── tensorflow
│ │ │ ├── .DS_Store
│ │ │ └── android
│ │ │ ├── .DS_Store
│ │ │ ├── audio
│ │ │ └── features
│ │ │ │ ├── FFT.java
│ │ │ │ ├── MFCC.java
│ │ │ │ ├── WavFile.java
│ │ │ │ └── WavFileException.java
│ │ │ └── noiseclassifier
│ │ │ ├── MainActivity.kt
│ │ │ └── Recognition.kt
│ └── res
│ │ ├── drawable-v24
│ │ └── ic_launcher_foreground.xml
│ │ ├── drawable
│ │ └── ic_launcher_background.xml
│ │ ├── layout
│ │ └── activity_main.xml
│ │ ├── mipmap-anydpi-v26
│ │ ├── ic_launcher.xml
│ │ └── ic_launcher_round.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ └── values
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── tensorflow
│ └── android
│ └── noiseclassifier
│ └── ExampleUnitTest.kt
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── local.properties
└── settings.gradle
/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VVasanth/Android_Tensorflow_AudioClassifier/3f8f58659d16e73405214b6bb400f6c156cab2a9/.DS_Store
--------------------------------------------------------------------------------
/.gradle/6.1.1/executionHistory/executionHistory.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VVasanth/Android_Tensorflow_AudioClassifier/3f8f58659d16e73405214b6bb400f6c156cab2a9/.gradle/6.1.1/executionHistory/executionHistory.bin
--------------------------------------------------------------------------------
/.gradle/6.1.1/executionHistory/executionHistory.lock:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VVasanth/Android_Tensorflow_AudioClassifier/3f8f58659d16e73405214b6bb400f6c156cab2a9/.gradle/6.1.1/executionHistory/executionHistory.lock
--------------------------------------------------------------------------------
/.gradle/6.1.1/fileChanges/last-build.bin:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.gradle/6.1.1/fileContent/fileContent.lock:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VVasanth/Android_Tensorflow_AudioClassifier/3f8f58659d16e73405214b6bb400f6c156cab2a9/.gradle/6.1.1/fileContent/fileContent.lock
--------------------------------------------------------------------------------
/.gradle/6.1.1/fileHashes/fileHashes.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VVasanth/Android_Tensorflow_AudioClassifier/3f8f58659d16e73405214b6bb400f6c156cab2a9/.gradle/6.1.1/fileHashes/fileHashes.bin
--------------------------------------------------------------------------------
/.gradle/6.1.1/fileHashes/fileHashes.lock:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VVasanth/Android_Tensorflow_AudioClassifier/3f8f58659d16e73405214b6bb400f6c156cab2a9/.gradle/6.1.1/fileHashes/fileHashes.lock
--------------------------------------------------------------------------------
/.gradle/6.1.1/fileHashes/resourceHashesCache.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VVasanth/Android_Tensorflow_AudioClassifier/3f8f58659d16e73405214b6bb400f6c156cab2a9/.gradle/6.1.1/fileHashes/resourceHashesCache.bin
--------------------------------------------------------------------------------
/.gradle/6.1.1/gc.properties:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VVasanth/Android_Tensorflow_AudioClassifier/3f8f58659d16e73405214b6bb400f6c156cab2a9/.gradle/6.1.1/gc.properties
--------------------------------------------------------------------------------
/.gradle/6.1.1/javaCompile/classAnalysis.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VVasanth/Android_Tensorflow_AudioClassifier/3f8f58659d16e73405214b6bb400f6c156cab2a9/.gradle/6.1.1/javaCompile/classAnalysis.bin
--------------------------------------------------------------------------------
/.gradle/6.1.1/javaCompile/jarAnalysis.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VVasanth/Android_Tensorflow_AudioClassifier/3f8f58659d16e73405214b6bb400f6c156cab2a9/.gradle/6.1.1/javaCompile/jarAnalysis.bin
--------------------------------------------------------------------------------
/.gradle/6.1.1/javaCompile/javaCompile.lock:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VVasanth/Android_Tensorflow_AudioClassifier/3f8f58659d16e73405214b6bb400f6c156cab2a9/.gradle/6.1.1/javaCompile/javaCompile.lock
--------------------------------------------------------------------------------
/.gradle/6.1.1/javaCompile/taskHistory.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VVasanth/Android_Tensorflow_AudioClassifier/3f8f58659d16e73405214b6bb400f6c156cab2a9/.gradle/6.1.1/javaCompile/taskHistory.bin
--------------------------------------------------------------------------------
/.gradle/buildOutputCleanup/buildOutputCleanup.lock:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VVasanth/Android_Tensorflow_AudioClassifier/3f8f58659d16e73405214b6bb400f6c156cab2a9/.gradle/buildOutputCleanup/buildOutputCleanup.lock
--------------------------------------------------------------------------------
/.gradle/buildOutputCleanup/cache.properties:
--------------------------------------------------------------------------------
1 | #Mon Jun 22 14:54:09 CDT 2020
2 | gradle.version=6.1.1
3 |
--------------------------------------------------------------------------------
/.gradle/buildOutputCleanup/outputFiles.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VVasanth/Android_Tensorflow_AudioClassifier/3f8f58659d16e73405214b6bb400f6c156cab2a9/.gradle/buildOutputCleanup/outputFiles.bin
--------------------------------------------------------------------------------
/.gradle/checksums/checksums.lock:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VVasanth/Android_Tensorflow_AudioClassifier/3f8f58659d16e73405214b6bb400f6c156cab2a9/.gradle/checksums/checksums.lock
--------------------------------------------------------------------------------
/.gradle/checksums/md5-checksums.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VVasanth/Android_Tensorflow_AudioClassifier/3f8f58659d16e73405214b6bb400f6c156cab2a9/.gradle/checksums/md5-checksums.bin
--------------------------------------------------------------------------------
/.gradle/checksums/sha1-checksums.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VVasanth/Android_Tensorflow_AudioClassifier/3f8f58659d16e73405214b6bb400f6c156cab2a9/.gradle/checksums/sha1-checksums.bin
--------------------------------------------------------------------------------
/.gradle/vcs-1/gc.properties:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VVasanth/Android_Tensorflow_AudioClassifier/3f8f58659d16e73405214b6bb400f6c156cab2a9/.gradle/vcs-1/gc.properties
--------------------------------------------------------------------------------
/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /workspace.xml
--------------------------------------------------------------------------------
/.idea/.name:
--------------------------------------------------------------------------------
1 | MFCCCalculator
--------------------------------------------------------------------------------
/.idea/caches/build_file_checksums.ser:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VVasanth/Android_Tensorflow_AudioClassifier/3f8f58659d16e73405214b6bb400f6c156cab2a9/.idea/caches/build_file_checksums.ser
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | xmlns:android
14 |
15 | ^$
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | xmlns:.*
25 |
26 | ^$
27 |
28 |
29 | BY_NAME
30 |
31 |
32 |
33 |
34 |
35 |
36 | .*:id
37 |
38 | http://schemas.android.com/apk/res/android
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | .*:name
48 |
49 | http://schemas.android.com/apk/res/android
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 | name
59 |
60 | ^$
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 | style
70 |
71 | ^$
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 | .*
81 |
82 | ^$
83 |
84 |
85 | BY_NAME
86 |
87 |
88 |
89 |
90 |
91 |
92 | .*
93 |
94 | http://schemas.android.com/apk/res/android
95 |
96 |
97 | ANDROID_ATTRIBUTE_ORDER
98 |
99 |
100 |
101 |
102 |
103 |
104 | .*
105 |
106 | .*
107 |
108 |
109 | BY_NAME
110 |
111 |
112 |
113 |
114 |
115 |
116 |
--------------------------------------------------------------------------------
/.idea/codeStyles/codeStyleConfig.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
20 |
21 |
--------------------------------------------------------------------------------
/.idea/jarRepositories.xml:
--------------------------------------------------------------------------------
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 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_activity_activity_1_0_0_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_annotation_annotation_1_1_0_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_appcompat_appcompat_1_1_0_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_appcompat_appcompat_resources_1_1_0_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_arch_core_core_common_2_1_0_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_arch_core_core_runtime_2_0_0_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_collection_collection_1_1_0_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_constraintlayout_constraintlayout_1_1_3_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_constraintlayout_constraintlayout_solver_1_1_3_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_core_core_1_3_0_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_core_core_ktx_1_3_0_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_cursoradapter_cursoradapter_1_0_0_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_customview_customview_1_0_0_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_drawerlayout_drawerlayout_1_0_0_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_fragment_fragment_1_1_0_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_interpolator_interpolator_1_0_0_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_common_2_1_0_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_livedata_2_0_0_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_livedata_core_2_0_0_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_runtime_2_1_0_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_viewmodel_2_1_0_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_loader_loader_1_0_0_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_savedstate_savedstate_1_0_0_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_test_core_1_2_0_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_test_espresso_espresso_core_3_2_0_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_test_espresso_espresso_idling_resource_3_2_0_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_test_ext_junit_1_1_1_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_test_monitor_1_2_0_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_test_runner_1_2_0_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_vectordrawable_vectordrawable_1_1_0_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_vectordrawable_vectordrawable_animated_1_1_0_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_versionedparcelable_versionedparcelable_1_1_0_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_viewpager_viewpager_1_0_0_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__com_google_code_findbugs_jsr305_2_0_1_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__com_squareup_javawriter_2_1_1_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__javax_inject_javax_inject_1_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__junit_junit_4_12_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__net_sf_kxml_kxml2_2_3_0_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__org_hamcrest_hamcrest_core_1_3_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__org_hamcrest_hamcrest_integration_1_3_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__org_hamcrest_hamcrest_library_1_3_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__org_jetbrains_annotations_13_0_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_android_extensions_runtime_1_3_72_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_1_3_72_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_common_1_3_72_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__org_tensorflow_tensorflow_lite_0_0_0_nightly_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__org_tensorflow_tensorflow_lite_support_0_0_0_nightly_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/modules/MFCCCalculator.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/.idea/modules/NoiseClassifier_Android_Tensorflow.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/.idea/modules/app/app.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 | generateDebugSources
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 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Android_NoiseClassification_Demo.mov:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VVasanth/Android_Tensorflow_AudioClassifier/3f8f58659d16e73405214b6bb400f6c156cab2a9/Android_NoiseClassification_Demo.mov
--------------------------------------------------------------------------------
/Android_NoiseClassification_demo.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VVasanth/Android_Tensorflow_AudioClassifier/3f8f58659d16e73405214b6bb400f6c156cab2a9/Android_NoiseClassification_demo.gif
--------------------------------------------------------------------------------
/Python_Notebook_Files/UrbanSound_200.csv:
--------------------------------------------------------------------------------
1 | slice_file_name,fsID,start,end,salience,fold,classID,class
2 | 100032-3-0-0.wav,100032,0.0,0.317551,1,5,3,dog_bark
3 | 100263-2-0-117.wav,100263,58.5,62.5,1,5,2,children_playing
4 | 100263-2-0-121.wav,100263,60.5,64.5,1,5,2,children_playing
5 | 100263-2-0-126.wav,100263,63.0,67.0,1,5,2,children_playing
6 | 100263-2-0-137.wav,100263,68.5,72.5,1,5,2,children_playing
7 | 100263-2-0-143.wav,100263,71.5,75.5,1,5,2,children_playing
8 | 100263-2-0-161.wav,100263,80.5,84.5,1,5,2,children_playing
9 | 100263-2-0-3.wav,100263,1.5,5.5,1,5,2,children_playing
10 | 100263-2-0-36.wav,100263,18.0,22.0,1,5,2,children_playing
11 | 100648-1-0-0.wav,100648,4.823402,5.471927,2,10,1,car_horn
12 | 100648-1-1-0.wav,100648,8.998279,10.052132,2,10,1,car_horn
13 | 100648-1-2-0.wav,100648,16.699509,17.104837,2,10,1,car_horn
14 | 100648-1-3-0.wav,100648,17.631764,19.253075,2,10,1,car_horn
15 | 100648-1-4-0.wav,100648,25.332994,27.197502,2,10,1,car_horn
16 | 100652-3-0-0.wav,100652,0.0,4.0,1,2,3,dog_bark
17 | 100652-3-0-1.wav,100652,0.5,4.5,1,2,3,dog_bark
18 | 100652-3-0-2.wav,100652,1.0,5.0,1,2,3,dog_bark
19 | 100652-3-0-3.wav,100652,1.5,5.5,1,2,3,dog_bark
20 | 100795-3-0-0.wav,100795,0.19179,4.19179,1,10,3,dog_bark
21 | 100795-3-1-0.wav,100795,13.059155,17.059155,1,10,3,dog_bark
22 | 100795-3-1-1.wav,100795,13.559155,17.559155,1,10,3,dog_bark
23 | 100795-3-1-2.wav,100795,14.059155,18.059155,1,10,3,dog_bark
24 | 100852-0-0-0.wav,100852,0.0,4.0,1,5,0,air_conditioner
25 | 100852-0-0-1.wav,100852,0.5,4.5,1,5,0,air_conditioner
26 | 100852-0-0-10.wav,100852,5.0,9.0,1,5,0,air_conditioner
27 | 100852-0-0-11.wav,100852,5.5,9.5,1,5,0,air_conditioner
28 | 100852-0-0-12.wav,100852,6.0,10.0,1,5,0,air_conditioner
29 | 100852-0-0-13.wav,100852,6.5,10.5,1,5,0,air_conditioner
30 | 100852-0-0-14.wav,100852,7.0,11.0,1,5,0,air_conditioner
31 | 100852-0-0-15.wav,100852,7.5,11.5,1,5,0,air_conditioner
32 | 100852-0-0-16.wav,100852,8.0,12.0,1,5,0,air_conditioner
33 | 100852-0-0-17.wav,100852,8.5,12.5,1,5,0,air_conditioner
34 | 100852-0-0-18.wav,100852,9.0,13.0,1,5,0,air_conditioner
35 | 100852-0-0-19.wav,100852,9.5,13.5,1,5,0,air_conditioner
36 | 100852-0-0-2.wav,100852,1.0,5.0,1,5,0,air_conditioner
37 | 100852-0-0-20.wav,100852,10.0,14.0,1,5,0,air_conditioner
38 | 100852-0-0-21.wav,100852,10.5,14.5,1,5,0,air_conditioner
39 | 100852-0-0-22.wav,100852,11.0,15.0,1,5,0,air_conditioner
40 | 100852-0-0-23.wav,100852,11.5,15.5,1,5,0,air_conditioner
41 | 100852-0-0-24.wav,100852,12.0,16.0,1,5,0,air_conditioner
42 | 100852-0-0-25.wav,100852,12.5,16.5,1,5,0,air_conditioner
43 | 100852-0-0-26.wav,100852,13.0,17.0,1,5,0,air_conditioner
44 | 100852-0-0-27.wav,100852,13.5,17.5,1,5,0,air_conditioner
45 | 100852-0-0-28.wav,100852,14.0,18.0,1,5,0,air_conditioner
46 | 100852-0-0-29.wav,100852,14.5,18.5,1,5,0,air_conditioner
47 | 100852-0-0-3.wav,100852,1.5,5.5,1,5,0,air_conditioner
48 | 100852-0-0-30.wav,100852,15.0,19.0,1,5,0,air_conditioner
49 | 100852-0-0-4.wav,100852,2.0,6.0,1,5,0,air_conditioner
50 | 100852-0-0-5.wav,100852,2.5,6.5,1,5,0,air_conditioner
51 | 100852-0-0-6.wav,100852,3.0,7.0,1,5,0,air_conditioner
52 | 100852-0-0-7.wav,100852,3.5,7.5,1,5,0,air_conditioner
53 | 100852-0-0-8.wav,100852,4.0,8.0,1,5,0,air_conditioner
54 | 100852-0-0-9.wav,100852,4.5,8.5,1,5,0,air_conditioner
55 | 101281-3-0-0.wav,101281,0.341333,4.341333,2,6,3,dog_bark
56 | 101281-3-0-14.wav,101281,7.341333,11.341333000000000,2,6,3,dog_bark
57 | 101281-3-0-5.wav,101281,2.841333,6.8413330000000000,2,6,3,dog_bark
58 | 101382-2-0-10.wav,101382,5.0,9.0,1,10,2,children_playing
59 | 101382-2-0-12.wav,101382,6.0,10.0,1,10,2,children_playing
60 | 101382-2-0-20.wav,101382,10.0,14.0,1,10,2,children_playing
61 | 101382-2-0-21.wav,101382,10.5,14.5,1,10,2,children_playing
62 | 101382-2-0-29.wav,101382,14.5,18.5,1,10,2,children_playing
63 | 101382-2-0-33.wav,101382,16.5,20.5,1,10,2,children_playing
64 | 101382-2-0-42.wav,101382,21.0,25.0,1,10,2,children_playing
65 | 101382-2-0-45.wav,101382,22.5,26.5,1,10,2,children_playing
66 | 101415-3-0-2.wav,101415,1.0,5.0,1,1,3,dog_bark
67 | 101415-3-0-3.wav,101415,1.5,5.5,1,1,3,dog_bark
68 | 101415-3-0-8.wav,101415,4.0,8.0,1,1,3,dog_bark
69 | 101729-0-0-1.wav,101729,0.5,4.5,2,9,0,air_conditioner
70 | 101729-0-0-11.wav,101729,5.5,9.5,2,9,0,air_conditioner
71 | 101729-0-0-12.wav,101729,6.0,10.0,2,9,0,air_conditioner
72 | 101729-0-0-13.wav,101729,6.5,10.5,2,9,0,air_conditioner
73 | 101729-0-0-14.wav,101729,7.0,11.0,2,9,0,air_conditioner
74 | 101729-0-0-16.wav,101729,8.0,12.0,2,9,0,air_conditioner
75 | 101729-0-0-17.wav,101729,8.5,12.5,2,9,0,air_conditioner
76 | 101729-0-0-18.wav,101729,9.0,13.0,2,9,0,air_conditioner
77 | 101729-0-0-19.wav,101729,9.5,13.5,2,9,0,air_conditioner
78 | 101729-0-0-21.wav,101729,10.5,14.5,2,9,0,air_conditioner
79 | 101729-0-0-22.wav,101729,11.0,15.0,2,9,0,air_conditioner
80 | 101729-0-0-23.wav,101729,11.5,15.5,2,9,0,air_conditioner
81 | 101729-0-0-24.wav,101729,12.0,16.0,2,9,0,air_conditioner
82 | 101729-0-0-26.wav,101729,13.0,17.0,2,9,0,air_conditioner
83 | 101729-0-0-28.wav,101729,14.0,18.0,2,9,0,air_conditioner
84 | 101729-0-0-29.wav,101729,14.5,18.5,2,9,0,air_conditioner
85 | 101729-0-0-3.wav,101729,1.5,5.5,2,9,0,air_conditioner
86 | 101729-0-0-32.wav,101729,16.0,20.0,2,9,0,air_conditioner
87 | 101729-0-0-33.wav,101729,16.5,20.5,2,9,0,air_conditioner
88 | 101729-0-0-36.wav,101729,18.0,22.0,2,9,0,air_conditioner
89 | 101729-0-0-37.wav,101729,18.5,22.5,2,9,0,air_conditioner
90 | 101729-0-0-38.wav,101729,19.0,23.0,2,9,0,air_conditioner
91 | 101729-0-0-39.wav,101729,19.5,23.5,2,9,0,air_conditioner
92 | 101729-0-0-4.wav,101729,2.0,6.0,2,9,0,air_conditioner
93 | 101729-0-0-40.wav,101729,20.0,24.0,2,9,0,air_conditioner
94 | 101729-0-0-6.wav,101729,3.0,7.0,2,9,0,air_conditioner
95 | 101729-0-0-9.wav,101729,4.5,8.5,2,9,0,air_conditioner
96 | 101848-9-0-0.wav,101848,0.0,4.0,1,7,9,street_music
97 | 101848-9-0-1.wav,101848,0.5,4.5,1,7,9,street_music
98 | 101848-9-0-2.wav,101848,1.0,5.0,1,7,9,street_music
99 | 101848-9-0-3.wav,101848,1.5,5.5,1,7,9,street_music
100 | 101848-9-0-8.wav,101848,4.0,8.0,1,7,9,street_music
101 | 101848-9-0-9.wav,101848,4.5,8.5,1,7,9,street_music
102 | 102102-3-0-0.wav,102102,1.573952,4.673824,2,4,3,dog_bark
103 | 102103-3-0-0.wav,102103,1.97603,2.508892,2,10,3,dog_bark
104 | 102103-3-1-0.wav,102103,4.179637,4.568182,2,10,3,dog_bark
105 | 102104-3-0-0.wav,102104,2.429279,3.241121,2,2,3,dog_bark
106 | 102105-3-0-0.wav,102105,2.041889,6.041889000000000,2,3,3,dog_bark
107 | 102106-3-0-0.wav,102106,2.243852,3.884477,2,1,3,dog_bark
108 | 102305-6-0-0.wav,102305,0.0,2.61161,1,1,6,gun_shot
109 | 102547-3-0-2.wav,102547,1.0,5.0,1,5,3,dog_bark
110 | 102547-3-0-7.wav,102547,3.5,7.5,1,5,3,dog_bark
111 | 102547-3-0-8.wav,102547,4.0,8.0,1,5,3,dog_bark
112 | 102842-3-0-1.wav,102842,0.5,4.5,2,1,3,dog_bark
113 | 102842-3-1-0.wav,102842,113.061785,117.061785,2,1,3,dog_bark
114 | 102842-3-1-5.wav,102842,115.561785,119.561785,2,1,3,dog_bark
115 | 102842-3-1-6.wav,102842,116.061785,120.061785,2,1,3,dog_bark
116 | 102853-8-0-0.wav,102853,0.0,4.0,2,7,8,siren
117 | 102853-8-0-1.wav,102853,0.5,4.5,2,7,8,siren
118 | 102853-8-0-2.wav,102853,1.0,5.0,2,7,8,siren
119 | 102853-8-0-3.wav,102853,1.5,5.5,2,7,8,siren
120 | 102853-8-0-4.wav,102853,2.0,6.0,2,7,8,siren
121 | 102853-8-0-5.wav,102853,2.5,6.5,2,7,8,siren
122 | 102853-8-0-6.wav,102853,3.0,7.0,2,7,8,siren
123 | 102853-8-1-0.wav,102853,27.214044,31.214044,2,7,8,siren
124 | 102857-5-0-0.wav,102857,0.0,4.0,1,10,5,engine_idling
125 | 102857-5-0-1.wav,102857,0.5,4.5,1,10,5,engine_idling
126 | 102857-5-0-10.wav,102857,5.0,9.0,1,10,5,engine_idling
127 | 102857-5-0-11.wav,102857,5.5,9.5,1,10,5,engine_idling
128 | 102857-5-0-12.wav,102857,6.0,10.0,1,10,5,engine_idling
129 | 102857-5-0-13.wav,102857,6.5,10.5,1,10,5,engine_idling
130 | 102857-5-0-14.wav,102857,7.0,11.0,1,10,5,engine_idling
131 | 102857-5-0-15.wav,102857,7.5,11.5,1,10,5,engine_idling
132 | 102857-5-0-16.wav,102857,8.0,12.0,1,10,5,engine_idling
133 | 102857-5-0-17.wav,102857,8.5,12.5,1,10,5,engine_idling
134 | 102857-5-0-18.wav,102857,9.0,13.0,1,10,5,engine_idling
135 | 102857-5-0-19.wav,102857,9.5,13.5,1,10,5,engine_idling
136 | 102857-5-0-2.wav,102857,1.0,5.0,1,10,5,engine_idling
137 | 102857-5-0-20.wav,102857,10.0,14.0,1,10,5,engine_idling
138 | 102857-5-0-21.wav,102857,10.5,14.5,1,10,5,engine_idling
139 | 102857-5-0-22.wav,102857,11.0,15.0,1,10,5,engine_idling
140 | 102857-5-0-23.wav,102857,11.5,15.5,1,10,5,engine_idling
141 | 102857-5-0-24.wav,102857,12.0,16.0,1,10,5,engine_idling
142 | 102857-5-0-25.wav,102857,12.5,16.5,1,10,5,engine_idling
143 | 102857-5-0-26.wav,102857,13.0,17.0,1,10,5,engine_idling
144 | 102857-5-0-27.wav,102857,13.5,17.5,1,10,5,engine_idling
145 | 102857-5-0-28.wav,102857,14.0,18.0,1,10,5,engine_idling
146 | 102857-5-0-29.wav,102857,14.5,18.5,1,10,5,engine_idling
147 | 102857-5-0-3.wav,102857,1.5,5.5,1,10,5,engine_idling
148 | 102857-5-0-30.wav,102857,15.0,19.0,1,10,5,engine_idling
149 | 102857-5-0-4.wav,102857,2.0,6.0,1,10,5,engine_idling
150 | 102857-5-0-5.wav,102857,2.5,6.5,1,10,5,engine_idling
151 | 102857-5-0-6.wav,102857,3.0,7.0,1,10,5,engine_idling
152 | 102857-5-0-7.wav,102857,3.5,7.5,1,10,5,engine_idling
153 | 102857-5-0-8.wav,102857,4.0,8.0,1,10,5,engine_idling
154 | 102857-5-0-9.wav,102857,4.5,8.5,1,10,5,engine_idling
155 | 102858-5-0-0.wav,102858,0.0,4.0,1,2,5,engine_idling
156 | 102858-5-0-1.wav,102858,0.5,4.5,1,2,5,engine_idling
157 | 102871-8-0-0.wav,102871,0.0,4.0,1,2,8,siren
158 | 102871-8-0-1.wav,102871,0.5,4.5,1,2,8,siren
159 | 102871-8-0-10.wav,102871,5.0,9.0,1,2,8,siren
160 | 102871-8-0-11.wav,102871,5.5,9.5,1,2,8,siren
161 | 102871-8-0-12.wav,102871,6.0,10.0,1,2,8,siren
162 | 102871-8-0-13.wav,102871,6.5,10.5,1,2,8,siren
163 | 102871-8-0-14.wav,102871,7.0,11.0,1,2,8,siren
164 | 102871-8-0-15.wav,102871,7.5,11.5,1,2,8,siren
165 | 102871-8-0-2.wav,102871,1.0,5.0,1,2,8,siren
166 | 102871-8-0-3.wav,102871,1.5,5.5,1,2,8,siren
167 | 102871-8-0-4.wav,102871,2.0,6.0,1,2,8,siren
168 | 102871-8-0-5.wav,102871,2.5,6.5,1,2,8,siren
169 | 102871-8-0-6.wav,102871,3.0,7.0,1,2,8,siren
170 | 102871-8-0-7.wav,102871,3.5,7.5,1,2,8,siren
171 | 102871-8-0-8.wav,102871,4.0,8.0,1,2,8,siren
172 | 102871-8-0-9.wav,102871,4.5,8.5,1,2,8,siren
173 | 103074-7-0-0.wav,103074,3.341279,7.341279,1,1,7,jackhammer
174 | 103074-7-0-1.wav,103074,3.841279,7.841279,1,1,7,jackhammer
175 | 103074-7-0-2.wav,103074,4.341279,8.341279,1,1,7,jackhammer
176 | 103074-7-1-0.wav,103074,22.517317,26.517317,1,1,7,jackhammer
177 | 103074-7-1-1.wav,103074,23.017317,27.017317,1,1,7,jackhammer
178 | 103074-7-1-2.wav,103074,23.517317,27.517317,1,1,7,jackhammer
179 | 103074-7-1-3.wav,103074,24.017317,28.017317,1,1,7,jackhammer
180 | 103074-7-1-4.wav,103074,24.517317,28.517317,1,1,7,jackhammer
181 | 103074-7-1-5.wav,103074,25.017317,29.017317,1,1,7,jackhammer
182 | 103074-7-1-6.wav,103074,25.517317,29.517317,1,1,7,jackhammer
183 | 103074-7-2-0.wav,103074,42.347083,43.727176,1,1,7,jackhammer
184 | 103074-7-3-0.wav,103074,46.632637,50.632637,1,1,7,jackhammer
185 | 103074-7-3-1.wav,103074,47.132637,51.132637,1,1,7,jackhammer
186 | 103074-7-3-2.wav,103074,47.632637,51.632637,1,1,7,jackhammer
187 | 103074-7-3-3.wav,103074,48.132637,52.132637,1,1,7,jackhammer
188 | 103074-7-4-0.wav,103074,60.651482,64.651482,1,1,7,jackhammer
189 | 103074-7-4-1.wav,103074,61.151482,65.151482,1,1,7,jackhammer
190 | 103074-7-4-2.wav,103074,61.651482,65.651482,1,1,7,jackhammer
191 | 103074-7-4-3.wav,103074,62.151482,66.151482,1,1,7,jackhammer
192 | 103074-7-4-4.wav,103074,62.651482,66.651482,1,1,7,jackhammer
193 | 103074-7-4-5.wav,103074,63.151482,67.151482,1,1,7,jackhammer
194 | 103074-7-4-6.wav,103074,63.651482,67.651482,1,1,7,jackhammer
195 | 103076-3-0-0.wav,103076,0.0,2.527184,1,8,3,dog_bark
196 | 103076-3-1-0.wav,103076,6.788349,7.756796,1,8,3,dog_bark
197 | 103076-3-2-0.wav,103076,10.265534,10.717475,1,8,3,dog_bark
198 | 103199-4-0-0.wav,103199,0.0,4.0,1,3,4,drilling
199 | 103199-4-0-3.wav,103199,1.5,5.5,1,3,4,drilling
200 | 103199-4-0-4.wav,103199,2.0,6.0,1,3,4,drilling
201 | 103199-4-0-5.wav,103199,2.5,6.5,1,3,4,drilling
202 | 103199-4-0-6.wav,103199,3.0,7.0,1,3,4,drilling
203 | 103199-4-1-0.wav,103199,16.097136,17.617205,2,3,4,drilling
204 | 103199-4-2-0.wav,103199,17.617205,21.617205,1,3,4,drilling
205 |
--------------------------------------------------------------------------------
/Python_Notebook_Files/Urban_cnn_model.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "code",
5 | "execution_count": 1,
6 | "metadata": {
7 | "colab": {},
8 | "colab_type": "code",
9 | "id": "tA_zGJTRf_gC"
10 | },
11 | "outputs": [],
12 | "source": [
13 | "import numpy as np"
14 | ]
15 | },
16 | {
17 | "cell_type": "code",
18 | "execution_count": 2,
19 | "metadata": {
20 | "colab": {},
21 | "colab_type": "code",
22 | "id": "5uRr-bWZWzAD"
23 | },
24 | "outputs": [],
25 | "source": [
26 | "#extracting data from csv files into numpy arrays\n",
27 | "from numpy import genfromtxt\n",
28 | "x_train = genfromtxt('train_data.csv', delimiter=',')\n",
29 | "y_train = genfromtxt('train_labels.csv', delimiter=',')\n",
30 | "x_test = genfromtxt('test_data.csv', delimiter=',')\n",
31 | "y_test = genfromtxt('test_labels.csv', delimiter=',')"
32 | ]
33 | },
34 | {
35 | "cell_type": "code",
36 | "execution_count": 3,
37 | "metadata": {
38 | "colab": {
39 | "base_uri": "https://localhost:8080/",
40 | "height": 34
41 | },
42 | "colab_type": "code",
43 | "id": "sUE1btJWW3bw",
44 | "outputId": "f74bc8b1-fee5-4efd-b851-b2337f69afb9"
45 | },
46 | "outputs": [
47 | {
48 | "data": {
49 | "text/plain": [
50 | "((153, 40), (50, 40), (153,), (50,))"
51 | ]
52 | },
53 | "execution_count": 3,
54 | "metadata": {},
55 | "output_type": "execute_result"
56 | }
57 | ],
58 | "source": [
59 | "#shape\n",
60 | "x_train.shape,x_test.shape,y_train.shape,y_test.shape"
61 | ]
62 | },
63 | {
64 | "cell_type": "code",
65 | "execution_count": 4,
66 | "metadata": {
67 | "colab": {
68 | "base_uri": "https://localhost:8080/",
69 | "height": 34
70 | },
71 | "colab_type": "code",
72 | "id": "UDbtZ-GaXEXS",
73 | "outputId": "50df72f3-2b7e-45b7-ea23-80e5aaca1743"
74 | },
75 | "outputs": [
76 | {
77 | "data": {
78 | "text/plain": [
79 | "((153, 10), (50, 10))"
80 | ]
81 | },
82 | "execution_count": 4,
83 | "metadata": {},
84 | "output_type": "execute_result"
85 | }
86 | ],
87 | "source": [
88 | "#converting to one hot\n",
89 | "from tensorflow.keras.utils import to_categorical\n",
90 | "y_train = to_categorical(y_train, num_classes=10)\n",
91 | "y_test = to_categorical(y_test, num_classes=10)\n",
92 | "y_train.shape,y_test.shape"
93 | ]
94 | },
95 | {
96 | "cell_type": "code",
97 | "execution_count": 6,
98 | "metadata": {
99 | "colab": {},
100 | "colab_type": "code",
101 | "id": "15K2y9sUgn_L"
102 | },
103 | "outputs": [],
104 | "source": [
105 | "#reshaping to shape required by CNN\n",
106 | "x_train=np.reshape(x_train,(x_train.shape[0], 40,1,1))\n",
107 | "x_test=np.reshape(x_test,(x_test.shape[0], 40,1,1))"
108 | ]
109 | },
110 | {
111 | "cell_type": "code",
112 | "execution_count": 7,
113 | "metadata": {
114 | "colab": {
115 | "base_uri": "https://localhost:8080/",
116 | "height": 34
117 | },
118 | "colab_type": "code",
119 | "id": "CgeQAvcdgtwn",
120 | "outputId": "fb3d635b-1da0-4c3d-f17f-50c9619cf9da"
121 | },
122 | "outputs": [
123 | {
124 | "data": {
125 | "text/plain": [
126 | "((153, 40, 1, 1), (50, 40, 1, 1))"
127 | ]
128 | },
129 | "execution_count": 7,
130 | "metadata": {},
131 | "output_type": "execute_result"
132 | }
133 | ],
134 | "source": [
135 | "#shapes\n",
136 | "x_train.shape,x_test.shape"
137 | ]
138 | },
139 | {
140 | "cell_type": "code",
141 | "execution_count": 8,
142 | "metadata": {
143 | "colab": {},
144 | "colab_type": "code",
145 | "id": "3bQ2gHc8f9n4"
146 | },
147 | "outputs": [
148 | {
149 | "name": "stdout",
150 | "output_type": "stream",
151 | "text": [
152 | "2.2.0\n"
153 | ]
154 | }
155 | ],
156 | "source": [
157 | "from tensorflow.keras import Sequential\n",
158 | "import tensorflow as tf\n",
159 | "print(tf.__version__)\n",
160 | "from tensorflow.keras.layers import Dense, Flatten, Conv2D, MaxPooling2D, Dropout\n",
161 | "from tensorflow.keras import Model"
162 | ]
163 | },
164 | {
165 | "cell_type": "code",
166 | "execution_count": 9,
167 | "metadata": {
168 | "colab": {},
169 | "colab_type": "code",
170 | "id": "SyjNa0N0gGlY"
171 | },
172 | "outputs": [],
173 | "source": [
174 | "#forming model\n",
175 | "model=Sequential()"
176 | ]
177 | },
178 | {
179 | "cell_type": "code",
180 | "execution_count": 10,
181 | "metadata": {
182 | "colab": {},
183 | "colab_type": "code",
184 | "id": "fUJUiyVTgkGZ"
185 | },
186 | "outputs": [],
187 | "source": [
188 | "#adding layers and forming the model\n",
189 | "model.add(Conv2D(64,kernel_size=5,strides=1,padding=\"Same\",activation=\"relu\",input_shape=(40,1,1)))\n",
190 | "model.add(MaxPooling2D(padding=\"same\"))\n",
191 | "\n",
192 | "model.add(Conv2D(128,kernel_size=5,strides=1,padding=\"same\",activation=\"relu\"))\n",
193 | "model.add(MaxPooling2D(padding=\"same\"))\n",
194 | "model.add(Dropout(0.3))\n",
195 | "\n",
196 | "model.add(Flatten())\n",
197 | "\n",
198 | "model.add(Dense(256,activation=\"relu\"))\n",
199 | "model.add(Dropout(0.3))\n",
200 | "\n",
201 | "model.add(Dense(512,activation=\"relu\"))\n",
202 | "model.add(Dropout(0.3))\n",
203 | "\n",
204 | "model.add(Dense(10,activation=\"softmax\"))"
205 | ]
206 | },
207 | {
208 | "cell_type": "code",
209 | "execution_count": 11,
210 | "metadata": {
211 | "colab": {},
212 | "colab_type": "code",
213 | "id": "ZHek_bnng3xp"
214 | },
215 | "outputs": [],
216 | "source": [
217 | "#compiling\n",
218 | "model.compile(optimizer=\"adam\",loss=\"categorical_crossentropy\",metrics=[\"accuracy\"])"
219 | ]
220 | },
221 | {
222 | "cell_type": "code",
223 | "execution_count": 12,
224 | "metadata": {
225 | "colab": {
226 | "base_uri": "https://localhost:8080/",
227 | "height": 1091
228 | },
229 | "colab_type": "code",
230 | "id": "Hc_E0cTog96t",
231 | "outputId": "4fb76b2e-08bc-4a38-d574-79490df067f5"
232 | },
233 | "outputs": [
234 | {
235 | "name": "stdout",
236 | "output_type": "stream",
237 | "text": [
238 | "Epoch 1/30\n",
239 | "4/4 [==============================] - 0s 48ms/step - loss: 2.0726 - accuracy: 0.2745 - val_loss: 3.3352 - val_accuracy: 0.1200\n",
240 | "Epoch 2/30\n",
241 | "4/4 [==============================] - 0s 13ms/step - loss: 1.6048 - accuracy: 0.4967 - val_loss: 3.6241 - val_accuracy: 0.1000\n",
242 | "Epoch 3/30\n",
243 | "4/4 [==============================] - 0s 13ms/step - loss: 1.3376 - accuracy: 0.5556 - val_loss: 4.1635 - val_accuracy: 0.1200\n",
244 | "Epoch 4/30\n",
245 | "4/4 [==============================] - 0s 13ms/step - loss: 1.0308 - accuracy: 0.7255 - val_loss: 4.1981 - val_accuracy: 0.1200\n",
246 | "Epoch 5/30\n",
247 | "4/4 [==============================] - 0s 13ms/step - loss: 0.7843 - accuracy: 0.7778 - val_loss: 4.3473 - val_accuracy: 0.1200\n",
248 | "Epoch 6/30\n",
249 | "4/4 [==============================] - 0s 12ms/step - loss: 0.7192 - accuracy: 0.7974 - val_loss: 4.4873 - val_accuracy: 0.1200\n",
250 | "Epoch 7/30\n",
251 | "4/4 [==============================] - 0s 13ms/step - loss: 0.5531 - accuracy: 0.8170 - val_loss: 4.0361 - val_accuracy: 0.1200\n",
252 | "Epoch 8/30\n",
253 | "4/4 [==============================] - 0s 13ms/step - loss: 0.4270 - accuracy: 0.8693 - val_loss: 3.6794 - val_accuracy: 0.1200\n",
254 | "Epoch 9/30\n",
255 | "4/4 [==============================] - 0s 13ms/step - loss: 0.3672 - accuracy: 0.9281 - val_loss: 3.8678 - val_accuracy: 0.1200\n",
256 | "Epoch 10/30\n",
257 | "4/4 [==============================] - 0s 14ms/step - loss: 0.2402 - accuracy: 0.9412 - val_loss: 4.3586 - val_accuracy: 0.1200\n",
258 | "Epoch 11/30\n",
259 | "4/4 [==============================] - 0s 12ms/step - loss: 0.2890 - accuracy: 0.9150 - val_loss: 3.7867 - val_accuracy: 0.1200\n",
260 | "Epoch 12/30\n",
261 | "4/4 [==============================] - 0s 12ms/step - loss: 0.1881 - accuracy: 0.9346 - val_loss: 3.5562 - val_accuracy: 0.1800\n",
262 | "Epoch 13/30\n",
263 | "4/4 [==============================] - 0s 12ms/step - loss: 0.2113 - accuracy: 0.9346 - val_loss: 3.8496 - val_accuracy: 0.7400\n",
264 | "Epoch 14/30\n",
265 | "4/4 [==============================] - 0s 12ms/step - loss: 0.2429 - accuracy: 0.9477 - val_loss: 3.5848 - val_accuracy: 0.7400\n",
266 | "Epoch 15/30\n",
267 | "4/4 [==============================] - 0s 13ms/step - loss: 0.1477 - accuracy: 0.9542 - val_loss: 3.2284 - val_accuracy: 0.7400\n",
268 | "Epoch 16/30\n",
269 | "4/4 [==============================] - 0s 15ms/step - loss: 0.1005 - accuracy: 0.9673 - val_loss: 3.2545 - val_accuracy: 0.7400\n",
270 | "Epoch 17/30\n",
271 | "4/4 [==============================] - 0s 16ms/step - loss: 0.0673 - accuracy: 0.9935 - val_loss: 3.5861 - val_accuracy: 0.7400\n",
272 | "Epoch 18/30\n",
273 | "4/4 [==============================] - 0s 16ms/step - loss: 0.0516 - accuracy: 0.9869 - val_loss: 3.7681 - val_accuracy: 0.7400\n",
274 | "Epoch 19/30\n",
275 | "4/4 [==============================] - 0s 15ms/step - loss: 0.0492 - accuracy: 0.9869 - val_loss: 4.0435 - val_accuracy: 0.7400\n",
276 | "Epoch 20/30\n",
277 | "4/4 [==============================] - 0s 17ms/step - loss: 0.0492 - accuracy: 0.9804 - val_loss: 4.2710 - val_accuracy: 0.7400\n",
278 | "Epoch 21/30\n",
279 | "4/4 [==============================] - 0s 15ms/step - loss: 0.0373 - accuracy: 0.9869 - val_loss: 4.4171 - val_accuracy: 0.7400\n",
280 | "Epoch 22/30\n",
281 | "4/4 [==============================] - 0s 15ms/step - loss: 0.0256 - accuracy: 0.9935 - val_loss: 4.4984 - val_accuracy: 0.7400\n",
282 | "Epoch 23/30\n",
283 | "4/4 [==============================] - 0s 15ms/step - loss: 0.0367 - accuracy: 0.9869 - val_loss: 4.3313 - val_accuracy: 0.7400\n",
284 | "Epoch 24/30\n",
285 | "4/4 [==============================] - 0s 15ms/step - loss: 0.0494 - accuracy: 0.9869 - val_loss: 4.3794 - val_accuracy: 0.7400\n",
286 | "Epoch 25/30\n",
287 | "4/4 [==============================] - 0s 15ms/step - loss: 0.0083 - accuracy: 1.0000 - val_loss: 4.4873 - val_accuracy: 0.7400\n",
288 | "Epoch 26/30\n",
289 | "4/4 [==============================] - 0s 16ms/step - loss: 0.0132 - accuracy: 0.9935 - val_loss: 4.6293 - val_accuracy: 0.7400\n",
290 | "Epoch 27/30\n",
291 | "4/4 [==============================] - 0s 15ms/step - loss: 0.0276 - accuracy: 0.9935 - val_loss: 4.4349 - val_accuracy: 0.7400\n",
292 | "Epoch 28/30\n",
293 | "4/4 [==============================] - 0s 17ms/step - loss: 0.0114 - accuracy: 1.0000 - val_loss: 4.4444 - val_accuracy: 0.7400\n",
294 | "Epoch 29/30\n",
295 | "4/4 [==============================] - 0s 14ms/step - loss: 0.0135 - accuracy: 1.0000 - val_loss: 4.6879 - val_accuracy: 0.7400\n",
296 | "Epoch 30/30\n",
297 | "4/4 [==============================] - 0s 15ms/step - loss: 0.0295 - accuracy: 0.9935 - val_loss: 4.8164 - val_accuracy: 0.7400\n"
298 | ]
299 | },
300 | {
301 | "data": {
302 | "text/plain": [
303 | ""
304 | ]
305 | },
306 | "execution_count": 12,
307 | "metadata": {},
308 | "output_type": "execute_result"
309 | }
310 | ],
311 | "source": [
312 | "#training the model\n",
313 | "model.fit(x_train,y_train,batch_size=50,epochs=30,validation_data=(x_test,y_test))"
314 | ]
315 | },
316 | {
317 | "cell_type": "code",
318 | "execution_count": 13,
319 | "metadata": {
320 | "colab": {
321 | "base_uri": "https://localhost:8080/",
322 | "height": 85
323 | },
324 | "colab_type": "code",
325 | "id": "N1Rp9FTYhBpZ",
326 | "outputId": "8ac2e5be-314a-4284-ea31-ddbfeda1d4de"
327 | },
328 | "outputs": [
329 | {
330 | "name": "stdout",
331 | "output_type": "stream",
332 | "text": [
333 | "5/5 [==============================] - 0s 2ms/step - loss: 0.0034 - accuracy: 1.0000\n",
334 | "2/2 [==============================] - 0s 2ms/step - loss: 4.8164 - accuracy: 0.7400\n",
335 | "[0.0033533996902406216, 1.0]\n",
336 | "[4.816380023956299, 0.7400000095367432]\n"
337 | ]
338 | }
339 | ],
340 | "source": [
341 | "#train and test loss and scores respectively\n",
342 | "train_loss_score=model.evaluate(x_train,y_train)\n",
343 | "test_loss_score=model.evaluate(x_test,y_test)\n",
344 | "print(train_loss_score)\n",
345 | "print(test_loss_score)"
346 | ]
347 | },
348 | {
349 | "cell_type": "code",
350 | "execution_count": 14,
351 | "metadata": {},
352 | "outputs": [
353 | {
354 | "name": "stdout",
355 | "output_type": "stream",
356 | "text": [
357 | "Model: \"sequential\"\n",
358 | "_________________________________________________________________\n",
359 | "Layer (type) Output Shape Param # \n",
360 | "=================================================================\n",
361 | "conv2d (Conv2D) (None, 40, 1, 64) 1664 \n",
362 | "_________________________________________________________________\n",
363 | "max_pooling2d (MaxPooling2D) (None, 20, 1, 64) 0 \n",
364 | "_________________________________________________________________\n",
365 | "conv2d_1 (Conv2D) (None, 20, 1, 128) 204928 \n",
366 | "_________________________________________________________________\n",
367 | "max_pooling2d_1 (MaxPooling2 (None, 10, 1, 128) 0 \n",
368 | "_________________________________________________________________\n",
369 | "dropout (Dropout) (None, 10, 1, 128) 0 \n",
370 | "_________________________________________________________________\n",
371 | "flatten (Flatten) (None, 1280) 0 \n",
372 | "_________________________________________________________________\n",
373 | "dense (Dense) (None, 256) 327936 \n",
374 | "_________________________________________________________________\n",
375 | "dropout_1 (Dropout) (None, 256) 0 \n",
376 | "_________________________________________________________________\n",
377 | "dense_1 (Dense) (None, 512) 131584 \n",
378 | "_________________________________________________________________\n",
379 | "dropout_2 (Dropout) (None, 512) 0 \n",
380 | "_________________________________________________________________\n",
381 | "dense_2 (Dense) (None, 10) 5130 \n",
382 | "=================================================================\n",
383 | "Total params: 671,242\n",
384 | "Trainable params: 671,242\n",
385 | "Non-trainable params: 0\n",
386 | "_________________________________________________________________\n"
387 | ]
388 | }
389 | ],
390 | "source": [
391 | "model.summary()"
392 | ]
393 | },
394 | {
395 | "cell_type": "code",
396 | "execution_count": 15,
397 | "metadata": {},
398 | "outputs": [
399 | {
400 | "name": "stdout",
401 | "output_type": "stream",
402 | "text": [
403 | "WARNING:tensorflow:From /Users/vishrud/opt/anaconda3/envs/kerasCPU3/lib/python3.6/site-packages/tensorflow/python/ops/resource_variable_ops.py:1817: calling BaseResourceVariable.__init__ (from tensorflow.python.ops.resource_variable_ops) with constraint is deprecated and will be removed in a future version.\n",
404 | "Instructions for updating:\n",
405 | "If using Keras pass *_constraint arguments to layers.\n",
406 | "INFO:tensorflow:Assets written to: urbanClassifier/assets\n"
407 | ]
408 | }
409 | ],
410 | "source": [
411 | "model.save('urbanClassifier')"
412 | ]
413 | },
414 | {
415 | "cell_type": "code",
416 | "execution_count": 16,
417 | "metadata": {},
418 | "outputs": [],
419 | "source": [
420 | "converter = tf.lite.TFLiteConverter.from_keras_model(model)\n",
421 | "tflite_model = converter.convert()\n",
422 | "\n",
423 | "# Save the TF Lite model.\n",
424 | "with tf.io.gfile.GFile('model.tflite', 'wb') as f:\n",
425 | " f.write(tflite_model)"
426 | ]
427 | },
428 | {
429 | "cell_type": "code",
430 | "execution_count": 17,
431 | "metadata": {},
432 | "outputs": [
433 | {
434 | "data": {
435 | "text/plain": [
436 | "(40, 1, 1)"
437 | ]
438 | },
439 | "execution_count": 17,
440 | "metadata": {},
441 | "output_type": "execute_result"
442 | }
443 | ],
444 | "source": [
445 | "x_test[0].shape"
446 | ]
447 | },
448 | {
449 | "cell_type": "code",
450 | "execution_count": 18,
451 | "metadata": {},
452 | "outputs": [],
453 | "source": [
454 | "testData = np.expand_dims(x_test[5],axis=0)"
455 | ]
456 | },
457 | {
458 | "cell_type": "code",
459 | "execution_count": 19,
460 | "metadata": {},
461 | "outputs": [
462 | {
463 | "name": "stdout",
464 | "output_type": "stream",
465 | "text": [
466 | "WARNING:tensorflow:From :1: Sequential.predict_classes (from tensorflow.python.keras.engine.sequential) is deprecated and will be removed after 2021-01-01.\n",
467 | "Instructions for updating:\n",
468 | "Please use instead:* `np.argmax(model.predict(x), axis=-1)`, if your model does multi-class classification (e.g. if it uses a `softmax` last-layer activation).* `(model.predict(x) > 0.5).astype(\"int32\")`, if your model does binary classification (e.g. if it uses a `sigmoid` last-layer activation).\n"
469 | ]
470 | },
471 | {
472 | "name": "stderr",
473 | "output_type": "stream",
474 | "text": [
475 | "WARNING:tensorflow:From :1: Sequential.predict_classes (from tensorflow.python.keras.engine.sequential) is deprecated and will be removed after 2021-01-01.\n",
476 | "Instructions for updating:\n",
477 | "Please use instead:* `np.argmax(model.predict(x), axis=-1)`, if your model does multi-class classification (e.g. if it uses a `softmax` last-layer activation).* `(model.predict(x) > 0.5).astype(\"int32\")`, if your model does binary classification (e.g. if it uses a `sigmoid` last-layer activation).\n"
478 | ]
479 | }
480 | ],
481 | "source": [
482 | "prediction = model.predict_classes(testData)"
483 | ]
484 | },
485 | {
486 | "cell_type": "code",
487 | "execution_count": 20,
488 | "metadata": {},
489 | "outputs": [
490 | {
491 | "data": {
492 | "text/plain": [
493 | "array([3])"
494 | ]
495 | },
496 | "execution_count": 20,
497 | "metadata": {},
498 | "output_type": "execute_result"
499 | }
500 | ],
501 | "source": [
502 | "prediction"
503 | ]
504 | },
505 | {
506 | "cell_type": "code",
507 | "execution_count": 21,
508 | "metadata": {},
509 | "outputs": [
510 | {
511 | "data": {
512 | "text/plain": [
513 | "array([0., 0., 0., 1., 0., 0., 0., 0., 0., 0.], dtype=float32)"
514 | ]
515 | },
516 | "execution_count": 21,
517 | "metadata": {},
518 | "output_type": "execute_result"
519 | }
520 | ],
521 | "source": [
522 | "y_test[5]"
523 | ]
524 | },
525 | {
526 | "cell_type": "code",
527 | "execution_count": 22,
528 | "metadata": {},
529 | "outputs": [],
530 | "source": [
531 | "# Load the TFLite model and allocate tensors.\n",
532 | "interpreter = tf.lite.Interpreter(model_path=\"model.tflite\")\n",
533 | "interpreter.allocate_tensors()\n",
534 | "\n",
535 | "# Get input and output tensors.\n",
536 | "input_details = interpreter.get_input_details()\n",
537 | "output_details = interpreter.get_output_details()"
538 | ]
539 | },
540 | {
541 | "cell_type": "code",
542 | "execution_count": 23,
543 | "metadata": {},
544 | "outputs": [
545 | {
546 | "data": {
547 | "text/plain": [
548 | "[{'name': 'conv2d_input',\n",
549 | " 'index': 0,\n",
550 | " 'shape': array([ 1, 40, 1, 1], dtype=int32),\n",
551 | " 'shape_signature': array([ 1, 40, 1, 1], dtype=int32),\n",
552 | " 'dtype': numpy.float32,\n",
553 | " 'quantization': (0.0, 0),\n",
554 | " 'quantization_parameters': {'scales': array([], dtype=float32),\n",
555 | " 'zero_points': array([], dtype=int32),\n",
556 | " 'quantized_dimension': 0},\n",
557 | " 'sparsity_parameters': {}}]"
558 | ]
559 | },
560 | "execution_count": 23,
561 | "metadata": {},
562 | "output_type": "execute_result"
563 | }
564 | ],
565 | "source": [
566 | "input_details"
567 | ]
568 | },
569 | {
570 | "cell_type": "code",
571 | "execution_count": 26,
572 | "metadata": {},
573 | "outputs": [],
574 | "source": [
575 | "testData = np.expand_dims(x_test[5],axis=0)\n",
576 | "atData = np.float32(testData)"
577 | ]
578 | },
579 | {
580 | "cell_type": "code",
581 | "execution_count": 25,
582 | "metadata": {},
583 | "outputs": [
584 | {
585 | "name": "stdout",
586 | "output_type": "stream",
587 | "text": [
588 | "float32\n",
589 | "(1, 40, 1, 1)\n",
590 | "[[7.1473175e-11 7.8754218e-11 7.2361290e-05 9.9991715e-01 4.1809503e-07\n",
591 | " 2.0054536e-08 2.4804867e-06 4.1848831e-09 7.6419092e-06 3.6501409e-09]]\n"
592 | ]
593 | }
594 | ],
595 | "source": [
596 | "input_shape = input_details[0]['shape']\n",
597 | "input_data = np.array(np.random.random_sample(input_shape), dtype=np.float32)\n",
598 | "interpreter.set_tensor(input_details[0]['index'], atData)\n",
599 | "print(input_data.dtype)\n",
600 | "print(testData.shape)\n",
601 | "interpreter.invoke()\n",
602 | "\n",
603 | "# The function `get_tensor()` returns a copy of the tensor data.\n",
604 | "# Use `tensor()` in order to get a pointer to the tensor.\n",
605 | "output_data = interpreter.get_tensor(output_details[0]['index'])\n",
606 | "print(output_data)"
607 | ]
608 | },
609 | {
610 | "cell_type": "code",
611 | "execution_count": null,
612 | "metadata": {},
613 | "outputs": [],
614 | "source": []
615 | }
616 | ],
617 | "metadata": {
618 | "accelerator": "GPU",
619 | "colab": {
620 | "collapsed_sections": [],
621 | "name": "Urban_cnn_model.ipynb",
622 | "provenance": [],
623 | "version": "0.3.2"
624 | },
625 | "kernelspec": {
626 | "display_name": "kerasCPU3",
627 | "language": "python",
628 | "name": "kerascpu3"
629 | },
630 | "language_info": {
631 | "codemirror_mode": {
632 | "name": "ipython",
633 | "version": 3
634 | },
635 | "file_extension": ".py",
636 | "mimetype": "text/x-python",
637 | "name": "python",
638 | "nbconvert_exporter": "python",
639 | "pygments_lexer": "ipython3",
640 | "version": "3.6.10"
641 | }
642 | },
643 | "nbformat": 4,
644 | "nbformat_minor": 1
645 | }
646 |
--------------------------------------------------------------------------------
/Python_Notebook_Files/Urban_data_preprocess.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "code",
5 | "execution_count": 1,
6 | "metadata": {
7 | "colab": {},
8 | "colab_type": "code",
9 | "id": "AUHre7lQ4eAF"
10 | },
11 | "outputs": [],
12 | "source": [
13 | "import pandas as pd\n",
14 | "import numpy as np\n",
15 | "import matplotlib.pyplot as plt\n",
16 | "import os\n",
17 | "from tqdm import tqdm"
18 | ]
19 | },
20 | {
21 | "cell_type": "code",
22 | "execution_count": 2,
23 | "metadata": {
24 | "colab": {},
25 | "colab_type": "code",
26 | "id": "VPLIlUJN4euz"
27 | },
28 | "outputs": [],
29 | "source": [
30 | "#forming a panda dataframe from the metadata file\n",
31 | "data=pd.read_csv(\"UrbanSound8K/metadata/UrbanSound_200.csv\")"
32 | ]
33 | },
34 | {
35 | "cell_type": "code",
36 | "execution_count": 6,
37 | "metadata": {
38 | "colab": {
39 | "base_uri": "https://localhost:8080/",
40 | "height": 204
41 | },
42 | "colab_type": "code",
43 | "id": "6Oa7rVd54g7A",
44 | "outputId": "5fcf3079-7b67-4f5a-bf04-64581579ec4b"
45 | },
46 | "outputs": [
47 | {
48 | "data": {
49 | "text/html": [
50 | "\n",
51 | "\n",
64 | "
\n",
65 | " \n",
66 | " \n",
67 | " | \n",
68 | " slice_file_name | \n",
69 | " fsID | \n",
70 | " start | \n",
71 | " end | \n",
72 | " salience | \n",
73 | " fold | \n",
74 | " classID | \n",
75 | " class | \n",
76 | "
\n",
77 | " \n",
78 | " \n",
79 | " \n",
80 | " 0 | \n",
81 | " 100032-3-0-0.wav | \n",
82 | " 100032 | \n",
83 | " 0.0 | \n",
84 | " 0.317551 | \n",
85 | " 1 | \n",
86 | " 5 | \n",
87 | " 3 | \n",
88 | " dog_bark | \n",
89 | "
\n",
90 | " \n",
91 | " 1 | \n",
92 | " 100263-2-0-117.wav | \n",
93 | " 100263 | \n",
94 | " 58.5 | \n",
95 | " 62.500000 | \n",
96 | " 1 | \n",
97 | " 5 | \n",
98 | " 2 | \n",
99 | " children_playing | \n",
100 | "
\n",
101 | " \n",
102 | " 2 | \n",
103 | " 100263-2-0-121.wav | \n",
104 | " 100263 | \n",
105 | " 60.5 | \n",
106 | " 64.500000 | \n",
107 | " 1 | \n",
108 | " 5 | \n",
109 | " 2 | \n",
110 | " children_playing | \n",
111 | "
\n",
112 | " \n",
113 | " 3 | \n",
114 | " 100263-2-0-126.wav | \n",
115 | " 100263 | \n",
116 | " 63.0 | \n",
117 | " 67.000000 | \n",
118 | " 1 | \n",
119 | " 5 | \n",
120 | " 2 | \n",
121 | " children_playing | \n",
122 | "
\n",
123 | " \n",
124 | " 4 | \n",
125 | " 100263-2-0-137.wav | \n",
126 | " 100263 | \n",
127 | " 68.5 | \n",
128 | " 72.500000 | \n",
129 | " 1 | \n",
130 | " 5 | \n",
131 | " 2 | \n",
132 | " children_playing | \n",
133 | "
\n",
134 | " \n",
135 | "
\n",
136 | "
"
137 | ],
138 | "text/plain": [
139 | " slice_file_name fsID start end salience fold classID \\\n",
140 | "0 100032-3-0-0.wav 100032 0.0 0.317551 1 5 3 \n",
141 | "1 100263-2-0-117.wav 100263 58.5 62.500000 1 5 2 \n",
142 | "2 100263-2-0-121.wav 100263 60.5 64.500000 1 5 2 \n",
143 | "3 100263-2-0-126.wav 100263 63.0 67.000000 1 5 2 \n",
144 | "4 100263-2-0-137.wav 100263 68.5 72.500000 1 5 2 \n",
145 | "\n",
146 | " class \n",
147 | "0 dog_bark \n",
148 | "1 children_playing \n",
149 | "2 children_playing \n",
150 | "3 children_playing \n",
151 | "4 children_playing "
152 | ]
153 | },
154 | "execution_count": 6,
155 | "metadata": {},
156 | "output_type": "execute_result"
157 | }
158 | ],
159 | "source": [
160 | "#head of the dataframe\n",
161 | "data.head()"
162 | ]
163 | },
164 | {
165 | "cell_type": "code",
166 | "execution_count": 12,
167 | "metadata": {
168 | "colab": {
169 | "base_uri": "https://localhost:8080/",
170 | "height": 204
171 | },
172 | "colab_type": "code",
173 | "id": "WB0QggJl4imK",
174 | "outputId": "f71085a3-9ce5-491c-de8e-a48ca6d287bd"
175 | },
176 | "outputs": [
177 | {
178 | "data": {
179 | "text/plain": [
180 | "10 50\n",
181 | "5 43\n",
182 | "1 31\n",
183 | "9 27\n",
184 | "2 23\n",
185 | "7 14\n",
186 | "3 8\n",
187 | "8 3\n",
188 | "6 3\n",
189 | "4 1\n",
190 | "Name: fold, dtype: int64"
191 | ]
192 | },
193 | "execution_count": 12,
194 | "metadata": {},
195 | "output_type": "execute_result"
196 | }
197 | ],
198 | "source": [
199 | "#count of datapoints in each of the folders\n",
200 | "data[\"fold\"].value_counts()"
201 | ]
202 | },
203 | {
204 | "cell_type": "code",
205 | "execution_count": 13,
206 | "metadata": {
207 | "colab": {},
208 | "colab_type": "code",
209 | "id": "AXnks9vV4kct"
210 | },
211 | "outputs": [],
212 | "source": [
213 | "from librosa import display\n",
214 | "import librosa"
215 | ]
216 | },
217 | {
218 | "cell_type": "code",
219 | "execution_count": 14,
220 | "metadata": {
221 | "colab": {
222 | "base_uri": "https://localhost:8080/",
223 | "height": 34
224 | },
225 | "colab_type": "code",
226 | "id": "PrpVl_uJFtRz",
227 | "outputId": "72ac220b-c616-4bab-e040-b1f1d6be20a5"
228 | },
229 | "outputs": [],
230 | "source": [
231 | "#feature set\n",
232 | "#This file is of a dog bark\n",
233 | "y,sr=librosa.load(\"UrbanSound8K/audio/fold5/100032-3-0-0.wav\")\n",
234 | "mfccs = librosa.feature.mfcc(y, sr, n_mfcc=40)"
235 | ]
236 | },
237 | {
238 | "cell_type": "code",
239 | "execution_count": 15,
240 | "metadata": {},
241 | "outputs": [
242 | {
243 | "name": "stdout",
244 | "output_type": "stream",
245 | "text": [
246 | "(49440,)\n",
247 | "[3.0517578e-05 3.0517578e-05 0.0000000e+00 ... 1.6174316e-03 1.9226074e-03\n",
248 | " 2.5634766e-03]\n"
249 | ]
250 | }
251 | ],
252 | "source": [
253 | "y,sr=librosa.load(\"UrbanSound8K/1995-1826-0003.wav\", sr=None)\n",
254 | "print(y.shape)\n",
255 | "print(y)\n",
256 | "#mfccs = librosa.feature.mfcc(y, sr, n_mfcc=40)"
257 | ]
258 | },
259 | {
260 | "cell_type": "code",
261 | "execution_count": 16,
262 | "metadata": {
263 | "colab": {
264 | "base_uri": "https://localhost:8080/",
265 | "height": 293
266 | },
267 | "colab_type": "code",
268 | "id": "MfAip77-F78F",
269 | "outputId": "1fd581e0-cad3-4444-ff81-91e749de3316"
270 | },
271 | "outputs": [
272 | {
273 | "data": {
274 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAo4AAAEYCAYAAADS2XcjAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAAefUlEQVR4nO3df6xkd3nf8c9n7r37o2tswGvjH7sODmzS2IZW8cYxFFUkMWETEOtAKEuqOkosWSAj2kaoxXUESHSrFBCNoDHVKqLGIdQ4USxbAWNwVIU/8GLWrbGzro02eIH1LpDFxPZie/feO0//mHPxsNw78507c+Y8M/N+SUd755yZO89+z5lzn/me73O+jggBAAAA/bSaDgAAAACTgcQRAAAARUgcAQAAUITEEQAAAEVIHAEAAFCExBEAAABFSBwBAABQhMQRwFBsH7Z9yvbW09Y/YDtsv9T2zdVzTnQtb+t67u/YPlCtP2b7Ltuv6dr+c7b/wvZx20/aftD2H9ieG+f/FQBmHYkjgFF4TNLbVx7YfoWkzac950MRcUbX8tnquX8g6Y8l/RdJL5F0kaSbJO2utr9M0lclfUfSKyLiLElvlbRT0gtq/V8BAH6CmTkGwDBsH5b0p5J2R8QvVes+IumHkv6zpIslfUDSkYj4w9Nee5akxyX9XkT8xRq//9OSXhQRb6jr/wAAKEOPI4BR2C/pTNu/UF0+fpukTxe87lWSNkm6vcdzrpL0l8OHCAAYFokjgFH5M0nXSHqdpEfU6Uns9h7b/1gtx6t1Z0s6HhFLPX7v2ZKOjTxaAMDA5psOAMDU+DNJX1bn0vQtq2z/yOm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Ao8v8B6xZh4Z1VYTQAAAAASUVORK5CYII=\n",
275 | "text/plain": [
276 | ""
277 | ]
278 | },
279 | "metadata": {
280 | "needs_background": "light"
281 | },
282 | "output_type": "display_data"
283 | }
284 | ],
285 | "source": [
286 | "#MFCC of dog bark\n",
287 | "import matplotlib.pyplot as plt\n",
288 | "plt.figure(figsize=(10,4))\n",
289 | "librosa.display.specshow(mfccs, x_axis='time')\n",
290 | "plt.colorbar()\n",
291 | "plt.title('MFCC')\n",
292 | "plt.tight_layout()"
293 | ]
294 | },
295 | {
296 | "cell_type": "code",
297 | "execution_count": 17,
298 | "metadata": {
299 | "colab": {},
300 | "colab_type": "code",
301 | "id": "b4xPM6yi4nxW"
302 | },
303 | "outputs": [
304 | {
305 | "name": "stderr",
306 | "output_type": "stream",
307 | "text": [
308 | "100%|██████████| 203/203 [00:24<00:00, 8.16it/s]\n"
309 | ]
310 | }
311 | ],
312 | "source": [
313 | "#preprocessing using only mfcc\n",
314 | "x_train=[]\n",
315 | "x_test=[]\n",
316 | "y_train=[]\n",
317 | "y_test=[]\n",
318 | "path=\"UrbanSound8K/audio/fold\"\n",
319 | "for i in tqdm(range(len(data))):\n",
320 | " fold_no=str(data.iloc[i][\"fold\"])\n",
321 | " file=data.iloc[i][\"slice_file_name\"]\n",
322 | " label=data.iloc[i][\"classID\"]\n",
323 | " filename=path+fold_no+\"/\"+file\n",
324 | " #print(filename)\n",
325 | " y,sr=librosa.load(filename)\n",
326 | " mfccs = np.mean(librosa.feature.mfcc(y, sr, n_mfcc=40).T,axis=0)\n",
327 | " #print(mfccs.shape,mfccs.max(),mfccs.min())\n",
328 | " if(fold_no!='10'):\n",
329 | " x_train.append(mfccs)\n",
330 | " y_train.append(label)\n",
331 | " else:\n",
332 | " x_test.append(mfccs)\n",
333 | " y_test.append(label)"
334 | ]
335 | },
336 | {
337 | "cell_type": "code",
338 | "execution_count": 18,
339 | "metadata": {
340 | "colab": {
341 | "base_uri": "https://localhost:8080/",
342 | "height": 34
343 | },
344 | "colab_type": "code",
345 | "id": "lGKy40lJ4pbJ",
346 | "outputId": "ba6c39b0-6e4e-4f92-9258-90dc34d9b8cc"
347 | },
348 | "outputs": [
349 | {
350 | "data": {
351 | "text/plain": [
352 | "203"
353 | ]
354 | },
355 | "execution_count": 18,
356 | "metadata": {},
357 | "output_type": "execute_result"
358 | }
359 | ],
360 | "source": [
361 | "len(x_train)+len(x_test)"
362 | ]
363 | },
364 | {
365 | "cell_type": "code",
366 | "execution_count": 19,
367 | "metadata": {
368 | "colab": {
369 | "base_uri": "https://localhost:8080/",
370 | "height": 34
371 | },
372 | "colab_type": "code",
373 | "id": "qm2H-y6X4rfa",
374 | "outputId": "adabc298-07c6-4b5d-c3e4-28e4c9a6f087"
375 | },
376 | "outputs": [
377 | {
378 | "data": {
379 | "text/plain": [
380 | "203"
381 | ]
382 | },
383 | "execution_count": 19,
384 | "metadata": {},
385 | "output_type": "execute_result"
386 | }
387 | ],
388 | "source": [
389 | "len(data)"
390 | ]
391 | },
392 | {
393 | "cell_type": "code",
394 | "execution_count": 20,
395 | "metadata": {
396 | "colab": {
397 | "base_uri": "https://localhost:8080/",
398 | "height": 34
399 | },
400 | "colab_type": "code",
401 | "id": "UZ67ZUVa4sy5",
402 | "outputId": "0e089e8f-16a2-4390-e8e0-e947401b6d91"
403 | },
404 | "outputs": [
405 | {
406 | "data": {
407 | "text/plain": [
408 | "((153, 40), (50, 40), (153,), (50,))"
409 | ]
410 | },
411 | "execution_count": 20,
412 | "metadata": {},
413 | "output_type": "execute_result"
414 | }
415 | ],
416 | "source": [
417 | "#converting the lists into numpy arrays\n",
418 | "x_train=np.array(x_train)\n",
419 | "x_test=np.array(x_test)\n",
420 | "y_train=np.array(y_train)\n",
421 | "y_test=np.array(y_test)\n",
422 | "x_train.shape,x_test.shape,y_train.shape,y_test.shape"
423 | ]
424 | },
425 | {
426 | "cell_type": "code",
427 | "execution_count": 22,
428 | "metadata": {
429 | "colab": {},
430 | "colab_type": "code",
431 | "id": "EJ2MbJzP41Xe"
432 | },
433 | "outputs": [],
434 | "source": [
435 | "#saving the data numpy arrays\n",
436 | "np.savetxt(\"train_data.csv\", x_train, delimiter=\",\")\n",
437 | "np.savetxt(\"test_data.csv\",x_test,delimiter=\",\")\n",
438 | "np.savetxt(\"train_labels.csv\",y_train,delimiter=\",\")\n",
439 | "np.savetxt(\"test_labels.csv\",y_test,delimiter=\",\")"
440 | ]
441 | },
442 | {
443 | "cell_type": "code",
444 | "execution_count": 24,
445 | "metadata": {},
446 | "outputs": [
447 | {
448 | "data": {
449 | "text/plain": [
450 | "(40,)"
451 | ]
452 | },
453 | "execution_count": 24,
454 | "metadata": {},
455 | "output_type": "execute_result"
456 | }
457 | ],
458 | "source": [
459 | "x_test[0].shape"
460 | ]
461 | },
462 | {
463 | "cell_type": "code",
464 | "execution_count": null,
465 | "metadata": {},
466 | "outputs": [],
467 | "source": []
468 | }
469 | ],
470 | "metadata": {
471 | "accelerator": "GPU",
472 | "colab": {
473 | "collapsed_sections": [],
474 | "name": "Urban_data_preprocess.ipynb",
475 | "provenance": [],
476 | "version": "0.3.2"
477 | },
478 | "kernelspec": {
479 | "display_name": "kerasCPU3",
480 | "language": "python",
481 | "name": "kerascpu3"
482 | },
483 | "language_info": {
484 | "codemirror_mode": {
485 | "name": "ipython",
486 | "version": 3
487 | },
488 | "file_extension": ".py",
489 | "mimetype": "text/x-python",
490 | "name": "python",
491 | "nbconvert_exporter": "python",
492 | "pygments_lexer": "ipython3",
493 | "version": "3.6.10"
494 | }
495 | },
496 | "nbformat": 4,
497 | "nbformat_minor": 1
498 | }
499 |
--------------------------------------------------------------------------------
/Python_Notebook_Files/model.tflite:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VVasanth/Android_Tensorflow_AudioClassifier/3f8f58659d16e73405214b6bb400f6c156cab2a9/Python_Notebook_Files/model.tflite
--------------------------------------------------------------------------------
/Python_Notebook_Files/test_labels.csv:
--------------------------------------------------------------------------------
1 | 1.000000000000000000e+00
2 | 1.000000000000000000e+00
3 | 1.000000000000000000e+00
4 | 1.000000000000000000e+00
5 | 1.000000000000000000e+00
6 | 3.000000000000000000e+00
7 | 3.000000000000000000e+00
8 | 3.000000000000000000e+00
9 | 3.000000000000000000e+00
10 | 2.000000000000000000e+00
11 | 2.000000000000000000e+00
12 | 2.000000000000000000e+00
13 | 2.000000000000000000e+00
14 | 2.000000000000000000e+00
15 | 2.000000000000000000e+00
16 | 2.000000000000000000e+00
17 | 2.000000000000000000e+00
18 | 3.000000000000000000e+00
19 | 3.000000000000000000e+00
20 | 5.000000000000000000e+00
21 | 5.000000000000000000e+00
22 | 5.000000000000000000e+00
23 | 5.000000000000000000e+00
24 | 5.000000000000000000e+00
25 | 5.000000000000000000e+00
26 | 5.000000000000000000e+00
27 | 5.000000000000000000e+00
28 | 5.000000000000000000e+00
29 | 5.000000000000000000e+00
30 | 5.000000000000000000e+00
31 | 5.000000000000000000e+00
32 | 5.000000000000000000e+00
33 | 5.000000000000000000e+00
34 | 5.000000000000000000e+00
35 | 5.000000000000000000e+00
36 | 5.000000000000000000e+00
37 | 5.000000000000000000e+00
38 | 5.000000000000000000e+00
39 | 5.000000000000000000e+00
40 | 5.000000000000000000e+00
41 | 5.000000000000000000e+00
42 | 5.000000000000000000e+00
43 | 5.000000000000000000e+00
44 | 5.000000000000000000e+00
45 | 5.000000000000000000e+00
46 | 5.000000000000000000e+00
47 | 5.000000000000000000e+00
48 | 5.000000000000000000e+00
49 | 5.000000000000000000e+00
50 | 5.000000000000000000e+00
51 |
--------------------------------------------------------------------------------
/Python_Notebook_Files/train_labels.csv:
--------------------------------------------------------------------------------
1 | 3.000000000000000000e+00
2 | 2.000000000000000000e+00
3 | 2.000000000000000000e+00
4 | 2.000000000000000000e+00
5 | 2.000000000000000000e+00
6 | 2.000000000000000000e+00
7 | 2.000000000000000000e+00
8 | 2.000000000000000000e+00
9 | 2.000000000000000000e+00
10 | 3.000000000000000000e+00
11 | 3.000000000000000000e+00
12 | 3.000000000000000000e+00
13 | 3.000000000000000000e+00
14 | 0.000000000000000000e+00
15 | 0.000000000000000000e+00
16 | 0.000000000000000000e+00
17 | 0.000000000000000000e+00
18 | 0.000000000000000000e+00
19 | 0.000000000000000000e+00
20 | 0.000000000000000000e+00
21 | 0.000000000000000000e+00
22 | 0.000000000000000000e+00
23 | 0.000000000000000000e+00
24 | 0.000000000000000000e+00
25 | 0.000000000000000000e+00
26 | 0.000000000000000000e+00
27 | 0.000000000000000000e+00
28 | 0.000000000000000000e+00
29 | 0.000000000000000000e+00
30 | 0.000000000000000000e+00
31 | 0.000000000000000000e+00
32 | 0.000000000000000000e+00
33 | 0.000000000000000000e+00
34 | 0.000000000000000000e+00
35 | 0.000000000000000000e+00
36 | 0.000000000000000000e+00
37 | 0.000000000000000000e+00
38 | 0.000000000000000000e+00
39 | 0.000000000000000000e+00
40 | 0.000000000000000000e+00
41 | 0.000000000000000000e+00
42 | 0.000000000000000000e+00
43 | 0.000000000000000000e+00
44 | 0.000000000000000000e+00
45 | 3.000000000000000000e+00
46 | 3.000000000000000000e+00
47 | 3.000000000000000000e+00
48 | 3.000000000000000000e+00
49 | 3.000000000000000000e+00
50 | 3.000000000000000000e+00
51 | 0.000000000000000000e+00
52 | 0.000000000000000000e+00
53 | 0.000000000000000000e+00
54 | 0.000000000000000000e+00
55 | 0.000000000000000000e+00
56 | 0.000000000000000000e+00
57 | 0.000000000000000000e+00
58 | 0.000000000000000000e+00
59 | 0.000000000000000000e+00
60 | 0.000000000000000000e+00
61 | 0.000000000000000000e+00
62 | 0.000000000000000000e+00
63 | 0.000000000000000000e+00
64 | 0.000000000000000000e+00
65 | 0.000000000000000000e+00
66 | 0.000000000000000000e+00
67 | 0.000000000000000000e+00
68 | 0.000000000000000000e+00
69 | 0.000000000000000000e+00
70 | 0.000000000000000000e+00
71 | 0.000000000000000000e+00
72 | 0.000000000000000000e+00
73 | 0.000000000000000000e+00
74 | 0.000000000000000000e+00
75 | 0.000000000000000000e+00
76 | 0.000000000000000000e+00
77 | 0.000000000000000000e+00
78 | 9.000000000000000000e+00
79 | 9.000000000000000000e+00
80 | 9.000000000000000000e+00
81 | 9.000000000000000000e+00
82 | 9.000000000000000000e+00
83 | 9.000000000000000000e+00
84 | 3.000000000000000000e+00
85 | 3.000000000000000000e+00
86 | 3.000000000000000000e+00
87 | 3.000000000000000000e+00
88 | 6.000000000000000000e+00
89 | 3.000000000000000000e+00
90 | 3.000000000000000000e+00
91 | 3.000000000000000000e+00
92 | 3.000000000000000000e+00
93 | 3.000000000000000000e+00
94 | 3.000000000000000000e+00
95 | 3.000000000000000000e+00
96 | 8.000000000000000000e+00
97 | 8.000000000000000000e+00
98 | 8.000000000000000000e+00
99 | 8.000000000000000000e+00
100 | 8.000000000000000000e+00
101 | 8.000000000000000000e+00
102 | 8.000000000000000000e+00
103 | 8.000000000000000000e+00
104 | 5.000000000000000000e+00
105 | 5.000000000000000000e+00
106 | 8.000000000000000000e+00
107 | 8.000000000000000000e+00
108 | 8.000000000000000000e+00
109 | 8.000000000000000000e+00
110 | 8.000000000000000000e+00
111 | 8.000000000000000000e+00
112 | 8.000000000000000000e+00
113 | 8.000000000000000000e+00
114 | 8.000000000000000000e+00
115 | 8.000000000000000000e+00
116 | 8.000000000000000000e+00
117 | 8.000000000000000000e+00
118 | 8.000000000000000000e+00
119 | 8.000000000000000000e+00
120 | 8.000000000000000000e+00
121 | 8.000000000000000000e+00
122 | 7.000000000000000000e+00
123 | 7.000000000000000000e+00
124 | 7.000000000000000000e+00
125 | 7.000000000000000000e+00
126 | 7.000000000000000000e+00
127 | 7.000000000000000000e+00
128 | 7.000000000000000000e+00
129 | 7.000000000000000000e+00
130 | 7.000000000000000000e+00
131 | 7.000000000000000000e+00
132 | 7.000000000000000000e+00
133 | 7.000000000000000000e+00
134 | 7.000000000000000000e+00
135 | 7.000000000000000000e+00
136 | 7.000000000000000000e+00
137 | 7.000000000000000000e+00
138 | 7.000000000000000000e+00
139 | 7.000000000000000000e+00
140 | 7.000000000000000000e+00
141 | 7.000000000000000000e+00
142 | 7.000000000000000000e+00
143 | 7.000000000000000000e+00
144 | 3.000000000000000000e+00
145 | 3.000000000000000000e+00
146 | 3.000000000000000000e+00
147 | 4.000000000000000000e+00
148 | 4.000000000000000000e+00
149 | 4.000000000000000000e+00
150 | 4.000000000000000000e+00
151 | 4.000000000000000000e+00
152 | 4.000000000000000000e+00
153 | 4.000000000000000000e+00
154 |
--------------------------------------------------------------------------------
/Readme.md:
--------------------------------------------------------------------------------
1 | Android app that helps in music classification based on Tensorflow models with the application of MFCC processing techniques.
2 |
3 | Refer this blog for the detailed overview:
4 |
5 | https://heartbeat.fritz.ai/noise-classification-in-android-mobile-app-with-tensorflow-lite-13dede0f5d44
6 |
--------------------------------------------------------------------------------
/SampleAudio/001_children_playing.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VVasanth/Android_Tensorflow_AudioClassifier/3f8f58659d16e73405214b6bb400f6c156cab2a9/SampleAudio/001_children_playing.wav
--------------------------------------------------------------------------------
/SampleAudio/001_dog_barking.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VVasanth/Android_Tensorflow_AudioClassifier/3f8f58659d16e73405214b6bb400f6c156cab2a9/SampleAudio/001_dog_barking.wav
--------------------------------------------------------------------------------
/SampleAudio/001_street_music.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VVasanth/Android_Tensorflow_AudioClassifier/3f8f58659d16e73405214b6bb400f6c156cab2a9/SampleAudio/001_street_music.wav
--------------------------------------------------------------------------------
/SampleAudio/002_dog_barking.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VVasanth/Android_Tensorflow_AudioClassifier/3f8f58659d16e73405214b6bb400f6c156cab2a9/SampleAudio/002_dog_barking.wav
--------------------------------------------------------------------------------
/app/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VVasanth/Android_Tensorflow_AudioClassifier/3f8f58659d16e73405214b6bb400f6c156cab2a9/app/.DS_Store
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'kotlin-android-extensions'
4 |
5 | android {
6 | compileSdkVersion 28
7 | buildToolsVersion "30.0.0"
8 |
9 | defaultConfig {
10 | applicationId "com.tensorflow.android.noiseclassifier"
11 | minSdkVersion 23
12 | targetSdkVersion 28
13 | versionCode 1
14 | versionName "1.0"
15 |
16 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
17 | }
18 |
19 | aaptOptions {
20 | noCompress "tflite"
21 | }
22 |
23 | buildTypes {
24 | release {
25 | minifyEnabled false
26 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
27 | }
28 | }
29 | }
30 |
31 | dependencies {
32 | implementation fileTree(dir: "libs", include: ["*.jar"])
33 | implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
34 | implementation 'androidx.core:core-ktx:1.3.0'
35 | implementation 'androidx.appcompat:appcompat:1.1.0'
36 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
37 | testImplementation 'junit:junit:4.12'
38 | androidTestImplementation 'androidx.test.ext:junit:1.1.1'
39 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
40 | implementation 'org.tensorflow:tensorflow-lite:0.0.0-nightly'
41 | implementation('org.tensorflow:tensorflow-lite-support:0.0.0-nightly') { changing = true }
42 | }
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/app/src/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VVasanth/Android_Tensorflow_AudioClassifier/3f8f58659d16e73405214b6bb400f6c156cab2a9/app/src/.DS_Store
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/tensorflow/android/noiseclassifier/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.tensorflow.android.noiseclassifier
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22 | assertEquals("com.tensorflow.android.noiseclassifier", appContext.packageName)
23 | }
24 | }
--------------------------------------------------------------------------------
/app/src/main/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VVasanth/Android_Tensorflow_AudioClassifier/3f8f58659d16e73405214b6bb400f6c156cab2a9/app/src/main/.DS_Store
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/app/src/main/assets/labels.txt:
--------------------------------------------------------------------------------
1 | air_conditioner,
2 | car_horn,
3 | children_playing,
4 | dog_bark,
5 | drilling,
6 | gun_shot,
7 | engine_idling,
8 | jackhammer,
9 | siren,
10 | street_music
--------------------------------------------------------------------------------
/app/src/main/assets/model.tflite:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VVasanth/Android_Tensorflow_AudioClassifier/3f8f58659d16e73405214b6bb400f6c156cab2a9/app/src/main/assets/model.tflite
--------------------------------------------------------------------------------
/app/src/main/java/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VVasanth/Android_Tensorflow_AudioClassifier/3f8f58659d16e73405214b6bb400f6c156cab2a9/app/src/main/java/.DS_Store
--------------------------------------------------------------------------------
/app/src/main/java/com/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VVasanth/Android_Tensorflow_AudioClassifier/3f8f58659d16e73405214b6bb400f6c156cab2a9/app/src/main/java/com/.DS_Store
--------------------------------------------------------------------------------
/app/src/main/java/com/tensorflow/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VVasanth/Android_Tensorflow_AudioClassifier/3f8f58659d16e73405214b6bb400f6c156cab2a9/app/src/main/java/com/tensorflow/.DS_Store
--------------------------------------------------------------------------------
/app/src/main/java/com/tensorflow/android/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VVasanth/Android_Tensorflow_AudioClassifier/3f8f58659d16e73405214b6bb400f6c156cab2a9/app/src/main/java/com/tensorflow/android/.DS_Store
--------------------------------------------------------------------------------
/app/src/main/java/com/tensorflow/android/audio/features/FFT.java:
--------------------------------------------------------------------------------
1 | package com.tensorflow.android.audio.features;
2 |
3 | /**
4 | * Fast Fourier Transform.
5 | *
6 | * last updated on June 15, 2002
7 | * description: FFT class for real signals. Upon entry, N contains the
8 | * numbers of points in the DFT, real[] and imaginary[] contain the real and
9 | * imaginary parts of the input. Upon return, real[] and imaginary[] contain the
10 | * DFT output. All signals run from 0 to N - 1
11 | * input: speech signal
12 | * output: real and imaginary part of DFT output
13 | *
14 | * @author Danny Su
15 | * @author Hanns Holger Rutz
16 | */
17 | public class FFT {
18 | double[] real;
19 | double[] imag;
20 |
21 | /**
22 | * Performs Fast Fourier Transformation in place.
23 | */
24 | public void process(double[] signal) {
25 | final int numPoints = signal.length;
26 | // initialize real & imag array
27 | real = signal;
28 | imag = new double[numPoints];
29 |
30 | // perform FFT using the real & imag array
31 | final double pi = Math.PI;
32 | final int numStages = (int) (Math.log(numPoints) / Math.log(2));
33 | final int halfNumPoints = numPoints >> 1;
34 | int j = halfNumPoints;
35 | // FFT time domain decomposition carried out by "bit reversal sorting"
36 | // algorithm
37 | int k;
38 | for (int i = 1; i < numPoints - 2; i++) {
39 | if (i < j) {
40 | // swap
41 | double tempReal = real[j];
42 | double tempImag = imag[j];
43 | real[j] = real[i];
44 | imag[j] = imag[i];
45 | real[i] = tempReal;
46 | imag[i] = tempImag;
47 | }
48 | k = halfNumPoints;
49 | while (k <= j) {
50 | j -= k;
51 | k >>= 1;
52 | }
53 | j += k;
54 | }
55 |
56 | // loop for each stage
57 | for (int stage = 1; stage <= numStages; stage++) {
58 | int LE = 1;
59 | for (int i = 0; i < stage; i++) {
60 | LE <<= 1;
61 | }
62 | final int LE2 = LE >> 1;
63 | double UR = 1;
64 | double UI = 0;
65 | // calculate sine & cosine values
66 | final double SR = Math.cos(pi / LE2);
67 | final double SI = -Math.sin(pi / LE2);
68 | // loop for each sub DFT
69 | for (int subDFT = 1; subDFT <= LE2; subDFT++) {
70 | // loop for each butterfly
71 | for (int butterfly = subDFT - 1; butterfly <= numPoints - 1; butterfly += LE) {
72 | int ip = butterfly + LE2;
73 | // butterfly calculation
74 | double tempReal = (double) (real[ip] * UR - imag[ip] * UI);
75 | double tempImag = (double) (real[ip] * UI + imag[ip] * UR);
76 | real[ip] = real[butterfly] - tempReal;
77 | imag[ip] = imag[butterfly] - tempImag;
78 | real[butterfly] += tempReal;
79 | imag[butterfly] += tempImag;
80 | }
81 |
82 | double tempUR = UR;
83 | UR = tempUR * SR - UI * SI;
84 | UI = tempUR * SI + UI * SR;
85 | }
86 | }
87 | }
88 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/tensorflow/android/audio/features/MFCC.java:
--------------------------------------------------------------------------------
1 | package com.tensorflow.android.audio.features;
2 |
3 | /**
4 | * Wav file abstraction layer.
5 | * Source based on http://www.labbookpages.co.uk/audio/javaWavFiles.html
6 | *
7 | *
8 | */
9 |
10 | public class MFCC {
11 |
12 | private static int n_mfcc = 40;
13 | private final static double fMin = 0.0;
14 | private final static int n_fft = 2048;
15 | private final static int hop_length = 512;
16 | private final static int n_mels = 128;
17 |
18 | private static double sampleRate = 44100.0;
19 | private final static double fMax = sampleRate/2.0;
20 |
21 | FFT fft = new FFT();
22 |
23 |
24 | public void setSampleRate(int sampleRateVal){
25 | sampleRate = sampleRateVal;
26 | }
27 |
28 | public void setN_mfcc(int n_mfccVal) {
29 | n_mfcc = n_mfccVal;
30 | }
31 |
32 | public float[] process(double[] doubleInputBuffer) {
33 | final double[][] mfccResult = dctMfcc(doubleInputBuffer);
34 | return finalshape(mfccResult);
35 | }
36 |
37 | //MFCC into 1d
38 | private float[] finalshape(double[][] mfccSpecTro){
39 | float[] finalMfcc = new float[mfccSpecTro[0].length * mfccSpecTro.length];
40 | int k = 0;
41 | for (int i = 0; i < mfccSpecTro[0].length; i++){
42 | for (int j = 0; j < mfccSpecTro.length; j++){
43 | finalMfcc[k] = (float) mfccSpecTro[j][i];
44 | k = k+1;
45 | }
46 | }
47 | return finalMfcc;
48 | }
49 |
50 | //DCT to mfcc, librosa
51 | private double[][] dctMfcc(double[] y){
52 | final double[][] specTroGram = powerToDb(melSpectrogram(y));
53 | final double[][] dctBasis = dctFilter(n_mfcc, n_mels);
54 | double[][] mfccSpecTro = new double[n_mfcc][specTroGram[0].length];
55 | for (int i = 0; i < n_mfcc; i++){
56 | for (int j = 0; j < specTroGram[0].length; j++){
57 | for (int k = 0; k < specTroGram.length; k++){
58 | mfccSpecTro[i][j] += dctBasis[i][k]*specTroGram[k][j];
59 | }
60 | }
61 | }
62 | return mfccSpecTro;
63 | }
64 |
65 |
66 | //mel spectrogram, librosa
67 | private double[][] melSpectrogram(double[] y){
68 | double[][] melBasis = melFilter();
69 | double[][] spectro = stftMagSpec(y);
70 | double[][] melS = new double[melBasis.length][spectro[0].length];
71 | for (int i = 0; i < melBasis.length; i++){
72 | for (int j = 0; j < spectro[0].length; j++){
73 | for (int k = 0; k < melBasis[0].length; k++){
74 | melS[i][j] += melBasis[i][k]*spectro[k][j];
75 | }
76 | }
77 | }
78 | return melS;
79 | }
80 |
81 |
82 | //stft, librosa
83 | private double[][] stftMagSpec(double[] y){
84 | //Short-time Fourier transform (STFT)
85 | final double[] fftwin = getWindow();
86 | //pad y with reflect mode so it's centered. This reflect padding implementation is
87 | // not perfect but works for this demo.
88 | double[] ypad = new double[n_fft+y.length];
89 | for (int i = 0; i < n_fft/2; i++){
90 | ypad[(n_fft/2)-i-1] = y[i+1];
91 | ypad[(n_fft/2)+y.length+i] = y[y.length-2-i];
92 | }
93 | for (int j = 0; j < y.length; j++){
94 | ypad[(n_fft/2)+j] = y[j];
95 | }
96 |
97 |
98 | final double[][] frame = yFrame(ypad);
99 | double[][] fftmagSpec = new double[1+n_fft/2][frame[0].length];
100 | double[] fftFrame = new double[n_fft];
101 | for (int k = 0; k < frame[0].length; k++){
102 | for (int l =0; l < n_fft; l++){
103 | fftFrame[l] = fftwin[l]*frame[l][k];
104 | }
105 | double[] magSpec = magSpectrogram(fftFrame);
106 | for (int i =0; i < 1+n_fft/2; i++){
107 | fftmagSpec[i][k] = magSpec[i];
108 | }
109 | }
110 | return fftmagSpec;
111 | }
112 |
113 | private double[] magSpectrogram(double[] frame){
114 | double[] magSpec = new double[frame.length];
115 | fft.process(frame);
116 | for (int m = 0; m < frame.length; m++) {
117 | magSpec[m] = fft.real[m] * fft.real[m] + fft.imag[m] * fft.imag[m];
118 | }
119 | return magSpec;
120 | }
121 |
122 |
123 | //get hann window, librosa
124 | private double[] getWindow(){
125 | //Return a Hann window for even n_fft.
126 | //The Hann window is a taper formed by using a raised cosine or sine-squared
127 | //with ends that touch zero.
128 | double[] win = new double[n_fft];
129 | for (int i = 0; i < n_fft; i++){
130 | win[i] = 0.5 - 0.5 * Math.cos(2.0*Math.PI*i/n_fft);
131 | }
132 | return win;
133 | }
134 |
135 | //frame, librosa
136 | private double[][] yFrame(double[] ypad){
137 | final int n_frames = 1 + (ypad.length - n_fft) / hop_length;
138 | double[][] winFrames = new double[n_fft][n_frames];
139 | for (int i = 0; i < n_fft; i++){
140 | for (int j = 0; j < n_frames; j++){
141 | winFrames[i][j] = ypad[j*hop_length+i];
142 | }
143 | }
144 | return winFrames;
145 | }
146 |
147 | //power to db, librosa
148 | private double[][] powerToDb(double[][] melS){
149 | //Convert a power spectrogram (amplitude squared) to decibel (dB) units
150 | // This computes the scaling ``10 * log10(S / ref)`` in a numerically
151 | // stable way.
152 | double[][] log_spec = new double[melS.length][melS[0].length];
153 | double maxValue = -100;
154 | for (int i = 0; i < melS.length; i++){
155 | for (int j = 0; j < melS[0].length; j++){
156 | double magnitude = Math.abs(melS[i][j]);
157 | if (magnitude > 1e-10){
158 | log_spec[i][j]=10.0*log10(magnitude);
159 | }else{
160 | log_spec[i][j]=10.0*(-10);
161 | }
162 | if (log_spec[i][j] > maxValue){
163 | maxValue = log_spec[i][j];
164 | }
165 | }
166 | }
167 |
168 | //set top_db to 80.0
169 | for (int i = 0; i < melS.length; i++){
170 | for (int j = 0; j < melS[0].length; j++){
171 | if (log_spec[i][j] < maxValue - 80.0){
172 | log_spec[i][j] = maxValue - 80.0;
173 | }
174 | }
175 | }
176 | //ref is disabled, maybe later.
177 | return log_spec;
178 | }
179 |
180 | //dct, librosa
181 | private double[][] dctFilter(int n_filters, int n_input){
182 | //Discrete cosine transform (DCT type-III) basis.
183 | double[][] basis = new double[n_filters][n_input];
184 | double[] samples = new double[n_input];
185 | for (int i = 0; i < n_input; i++){
186 | samples[i] = (1 + 2*i) * Math.PI/(2.0*(n_input));
187 | }
188 | for (int j = 0; j < n_input; j++){
189 | basis[0][j] = 1.0/Math.sqrt(n_input);
190 | }
191 | for (int i = 1; i < n_filters; i++){
192 | for (int j = 0; j < n_input; j++){
193 | basis[i][j] = Math.cos(i*samples[j]) * Math.sqrt(2.0/(n_input));
194 | }
195 | }
196 | return basis;
197 | }
198 |
199 |
200 | //mel, librosa
201 | private double[][] melFilter(){
202 | //Create a Filterbank matrix to combine FFT bins into Mel-frequency bins.
203 | // Center freqs of each FFT bin
204 | final double[] fftFreqs = fftFreq();
205 | //'Center freqs' of mel bands - uniformly spaced between limits
206 | final double[] melF = melFreq(n_mels+2);
207 |
208 | double[] fdiff = new double[melF.length-1];
209 | for (int i = 0; i < melF.length-1; i++){
210 | fdiff[i] = melF[i+1]-melF[i];
211 | }
212 |
213 | double[][] ramps = new double[melF.length][fftFreqs.length];
214 | for (int i = 0; i < melF.length; i++){
215 | for (int j = 0; j < fftFreqs.length; j++){
216 | ramps[i][j] = melF[i]-fftFreqs[j];
217 | }
218 | }
219 |
220 | double[][] weights = new double[n_mels][1+n_fft/2];
221 | for (int i = 0; i < n_mels; i++){
222 | for (int j = 0; j < fftFreqs.length; j++){
223 | double lowerF = -ramps[i][j] / fdiff[i];
224 | double upperF = ramps[i+2][j] / fdiff[i+1];
225 | if (lowerF > upperF && upperF>0){
226 | weights[i][j] = upperF;
227 | }else if (lowerF > upperF && upperF<0){
228 | weights[i][j] = 0;
229 | }else if (lowerF < upperF && lowerF>0){
230 | weights[i][j] =lowerF;
231 | }else if (lowerF < upperF && lowerF<0){
232 | weights[i][j] = 0;
233 | }else {}
234 | }
235 | }
236 |
237 | double enorm[] = new double[n_mels];
238 | for (int i = 0; i < n_mels; i++){
239 | enorm[i] = 2.0 / (melF[i+2]-melF[i]);
240 | for (int j = 0; j < fftFreqs.length; j++){
241 | weights[i][j] *= enorm[i];
242 | }
243 | }
244 | return weights;
245 |
246 | //need to check if there's an empty channel somewhere
247 | }
248 |
249 | //fft frequencies, librosa
250 | private double[] fftFreq() {
251 | //Alternative implementation of np.fft.fftfreqs
252 | double[] freqs = new double[1+n_fft/2];
253 | for (int i = 0; i < 1+n_fft/2; i++){
254 | freqs[i] = 0 + (sampleRate/2)/(n_fft/2) * i;
255 | }
256 | return freqs;
257 | }
258 |
259 | //mel frequencies, librosa
260 | private double[] melFreq(int numMels) {
261 | //'Center freqs' of mel bands - uniformly spaced between limits
262 | double[] LowFFreq = new double[1];
263 | double[] HighFFreq = new double[1];
264 | LowFFreq[0] = fMin;
265 | HighFFreq[0] = fMax;
266 | final double[] melFLow = freqToMel(LowFFreq);
267 | final double[] melFHigh = freqToMel(HighFFreq);
268 | double[] mels = new double[numMels];
269 | for (int i = 0; i < numMels; i++) {
270 | mels[i] = melFLow[0] + (melFHigh[0] - melFLow[0]) / (numMels-1) * i;
271 | }
272 | return melToFreq(mels);
273 | }
274 |
275 |
276 | //mel to hz, htk, librosa
277 | private double[] melToFreqS(double[] mels) {
278 | double[] freqs = new double[mels.length];
279 | for (int i = 0; i < mels.length; i++) {
280 | freqs[i] = 700.0 * (Math.pow(10, mels[i]/2595.0) - 1.0);
281 | }
282 | return freqs;
283 | }
284 |
285 |
286 | // hz to mel, htk, librosa
287 | protected double[] freqToMelS(double[] freqs) {
288 | double[] mels = new double[freqs.length];
289 | for (int i = 0; i < freqs.length; i++){
290 | mels[i] = 2595.0 * log10(1.0 + freqs[i]/700.0);
291 | }
292 | return mels;
293 | }
294 |
295 | //mel to hz, Slaney, librosa
296 | private double[] melToFreq(double[] mels) {
297 | // Fill in the linear scale
298 | final double f_min = 0.0;
299 | final double f_sp = 200.0 / 3;
300 | double[] freqs = new double[mels.length];
301 |
302 | // And now the nonlinear scale
303 | final double min_log_hz = 1000.0; // beginning of log region (Hz)
304 | final double min_log_mel = (min_log_hz - f_min) / f_sp; // same (Mels)
305 | final double logstep = Math.log(6.4) / 27.0;
306 |
307 | for (int i = 0; i < mels.length; i++) {
308 | if (mels[i] < min_log_mel){
309 | freqs[i] = f_min + f_sp * mels[i];
310 | }else{
311 | freqs[i] = min_log_hz * Math.exp(logstep * (mels[i] - min_log_mel));
312 | }
313 | }
314 | return freqs;
315 | }
316 |
317 |
318 | // hz to mel, Slaney, librosa
319 | protected double[] freqToMel(double[] freqs) {
320 | final double f_min = 0.0;
321 | final double f_sp = 200.0 / 3;
322 | double[] mels = new double[freqs.length];
323 |
324 | // Fill in the log-scale part
325 |
326 | final double min_log_hz = 1000.0; // beginning of log region (Hz)
327 | final double min_log_mel = (min_log_hz - f_min) / f_sp ; // # same (Mels)
328 | final double logstep = Math.log(6.4) / 27.0; // step size for log region
329 |
330 | for (int i = 0; i < freqs.length; i++) {
331 | if (freqs[i] < min_log_hz){
332 | mels[i] = (freqs[i] - f_min) / f_sp;
333 | }else{
334 | mels[i] = min_log_mel + Math.log(freqs[i]/min_log_hz) / logstep;
335 | }
336 | }
337 | return mels;
338 | }
339 |
340 | // log10
341 | private double log10(double value) {
342 | return Math.log(value) / Math.log(10);
343 | }
344 | }
345 |
--------------------------------------------------------------------------------
/app/src/main/java/com/tensorflow/android/audio/features/WavFile.java:
--------------------------------------------------------------------------------
1 | package com.tensorflow.android.audio.features;
2 |
3 | import java.io.ByteArrayOutputStream;
4 | import java.io.File;
5 | import java.io.FileInputStream;
6 | import java.io.FileOutputStream;
7 | import java.io.IOException;
8 | import java.math.RoundingMode;
9 | import java.text.DecimalFormat;
10 |
11 | /*
12 | Source based on https://github.com/Semantive/waveform-android/blob/master/library/src/main/java/com/semantive/waveformandroid/waveform/soundfile/WavFile.java
13 | */
14 |
15 | public class WavFile {
16 | private enum IOState {READING, WRITING, CLOSED}
17 |
18 | private final static int BUFFER_SIZE = 4096;
19 |
20 | private final static int FMT_CHUNK_ID = 0x20746D66;
21 | private final static int DATA_CHUNK_ID = 0x61746164;
22 | private final static int RIFF_CHUNK_ID = 0x46464952;
23 | private final static int RIFF_TYPE_ID = 0x45564157;
24 |
25 | private File file; // File that will be read from or written to
26 | private IOState ioState; // Specifies the IO State of the Wav File (used for snaity checking)
27 | private int bytesPerSample; // Number of bytes required to store a single sample
28 | private long numFrames; // Number of frames within the data section
29 | private FileOutputStream oStream; // Output stream used for writting data
30 | private FileInputStream iStream; // Input stream used for reading data
31 | private float floatScale; // Scaling factor used for int <-> float conversion
32 | private float floatOffset; // Offset factor used for int <-> float conversion
33 | private boolean wordAlignAdjust; // Specify if an extra byte at the end of the data chunk is required for word alignment
34 |
35 | // Wav Header
36 | private int numChannels; // 2 bytes unsigned, 0x0001 (1) to 0xFFFF (65,535)
37 | private long sampleRate; // 4 bytes unsigned, 0x00000001 (1) to 0xFFFFFFFF (4,294,967,295)
38 | // Although a java int is 4 bytes, it is signed, so need to use a long
39 | private int blockAlign; // 2 bytes unsigned, 0x0001 (1) to 0xFFFF (65,535)
40 | private int validBits; // 2 bytes unsigned, 0x0002 (2) to 0xFFFF (65,535)
41 |
42 | // Buffering
43 | private byte[] buffer; // Local buffer used for IO
44 | private int bufferPointer; // Points to the current position in local buffer
45 | private int bytesRead; // Bytes read after last read into local buffer
46 | private long frameCounter; // Current number of frames read or written
47 | private long fileSize;
48 |
49 | // Cannot instantiate WavFile directly, must either use newWavFile() or openWavFile()
50 | private WavFile() {
51 | buffer = new byte[BUFFER_SIZE];
52 | }
53 |
54 | public int getNumChannels() {
55 | return numChannels;
56 | }
57 |
58 | public long getNumFrames() {
59 | return numFrames;
60 | }
61 |
62 | public long getFramesRemaining() {
63 | return numFrames - frameCounter;
64 | }
65 |
66 | public long getSampleRate() {
67 | return sampleRate;
68 | }
69 |
70 | public int getValidBits() {
71 | return validBits;
72 | }
73 |
74 | public long getDuration() {
75 | return getNumFrames() / getSampleRate();
76 | }
77 |
78 | public long getFileSize() {
79 | return fileSize;
80 | }
81 |
82 | public static WavFile openWavFile(File file) throws IOException, WavFileException {
83 | // Instantiate new Wavfile and store the file reference
84 | WavFile wavFile = new WavFile();
85 | wavFile.file = file;
86 |
87 | // Create a new file input stream for reading file data
88 | wavFile.iStream = new FileInputStream(file);
89 |
90 | // Read the first 12 bytes of the file
91 | int bytesRead = wavFile.iStream.read(wavFile.buffer, 0, 12);
92 | if (bytesRead != 12) throw new WavFileException("Not enough wav file bytes for header");
93 |
94 | // Extract parts from the header
95 | long riffChunkID = getLE(wavFile.buffer, 0, 4);
96 | long chunkSize = getLE(wavFile.buffer, 4, 4);
97 | long riffTypeID = getLE(wavFile.buffer, 8, 4);
98 |
99 | // Check the header bytes contains the correct signature
100 | if (riffChunkID != RIFF_CHUNK_ID)
101 | throw new WavFileException("Invalid Wav Header data, incorrect riff chunk ID");
102 | if (riffTypeID != RIFF_TYPE_ID) throw new WavFileException("Invalid Wav Header data, incorrect riff type ID");
103 |
104 | // Check that the file size matches the number of bytes listed in header
105 | if (file.length() != chunkSize + 8) {
106 | throw new WavFileException("Header chunk size (" + chunkSize + ") does not match file size (" + file.length() + ")");
107 | }
108 |
109 | wavFile.fileSize = chunkSize;
110 |
111 | boolean foundFormat = false;
112 | boolean foundData = false;
113 |
114 | // Search for the Format and Data Chunks
115 | while (true) {
116 | // Read the first 8 bytes of the chunk (ID and chunk size)
117 | bytesRead = wavFile.iStream.read(wavFile.buffer, 0, 8);
118 | if (bytesRead == -1) throw new WavFileException("Reached end of file without finding format chunk");
119 | if (bytesRead != 8) throw new WavFileException("Could not read chunk header");
120 |
121 | // Extract the chunk ID and Size
122 | long chunkID = getLE(wavFile.buffer, 0, 4);
123 | chunkSize = getLE(wavFile.buffer, 4, 4);
124 |
125 | // Word align the chunk size
126 | // chunkSize specifies the number of bytes holding data. However,
127 | // the data should be word aligned (2 bytes) so we need to calculate
128 | // the actual number of bytes in the chunk
129 | long numChunkBytes = (chunkSize % 2 == 1) ? chunkSize + 1 : chunkSize;
130 |
131 | if (chunkID == FMT_CHUNK_ID) {
132 | // Flag that the format chunk has been found
133 | foundFormat = true;
134 |
135 | // Read in the header info
136 | bytesRead = wavFile.iStream.read(wavFile.buffer, 0, 16);
137 |
138 | // Check this is uncompressed data
139 | int compressionCode = (int) getLE(wavFile.buffer, 0, 2);
140 | if (compressionCode != 1)
141 | throw new WavFileException("Compression Code " + compressionCode + " not supported");
142 |
143 | // Extract the format information
144 | wavFile.numChannels = (int) getLE(wavFile.buffer, 2, 2);
145 | wavFile.sampleRate = getLE(wavFile.buffer, 4, 4);
146 | wavFile.blockAlign = (int) getLE(wavFile.buffer, 12, 2);
147 | wavFile.validBits = (int) getLE(wavFile.buffer, 14, 2);
148 |
149 | if (wavFile.numChannels == 0)
150 | throw new WavFileException("Number of channels specified in header is equal to zero");
151 | if (wavFile.blockAlign == 0)
152 | throw new WavFileException("Block Align specified in header is equal to zero");
153 | if (wavFile.validBits < 2) throw new WavFileException("Valid Bits specified in header is less than 2");
154 | if (wavFile.validBits > 64)
155 | throw new WavFileException("Valid Bits specified in header is greater than 64, this is greater than a long can hold");
156 |
157 | // Calculate the number of bytes required to hold 1 sample
158 | wavFile.bytesPerSample = (wavFile.validBits + 7) / 8;
159 | if (wavFile.bytesPerSample * wavFile.numChannels != wavFile.blockAlign)
160 | throw new WavFileException("Block Align does not agree with bytes required for validBits and number of channels");
161 |
162 | // Account for number of format bytes and then skip over
163 | // any extra format bytes
164 | numChunkBytes -= 16;
165 | if (numChunkBytes > 0) wavFile.iStream.skip(numChunkBytes);
166 | } else if (chunkID == DATA_CHUNK_ID) {
167 | // Check if we've found the format chunk,
168 | // If not, throw an exception as we need the format information
169 | // before we can read the data chunk
170 | if (foundFormat == false) throw new WavFileException("Data chunk found before Format chunk");
171 |
172 | // Check that the chunkSize (wav data length) is a multiple of the
173 | // block align (bytes per frame)
174 | if (chunkSize % wavFile.blockAlign != 0)
175 | throw new WavFileException("Data Chunk size is not multiple of Block Align");
176 |
177 | // Calculate the number of frames
178 | wavFile.numFrames = chunkSize / wavFile.blockAlign;
179 |
180 | // Flag that we've found the wave data chunk
181 | foundData = true;
182 | /* byte[] data = null;
183 | final ByteArrayOutputStream baout = new ByteArrayOutputStream();
184 | int c;
185 | while ((c = wavFile.iStream.read(wavFile.buffer, 0, 16)) != -1) {
186 | baout.write(wavFile.buffer, 0, c);
187 | }
188 |
189 | baout.close();
190 | data = baout.toByteArray();
191 |
192 | double[] doubleInputBuffer = new double[data.length];
193 | int j = 0;
194 | for (int i = 0; i < data.length; i++) {
195 | doubleInputBuffer[i] = data[i] / 32767.0;
196 | j = j + 1;
197 | }
198 |
199 |
200 | MFCC mfccConvert = new MFCC();
201 | float[] mfccInput = mfccConvert.process(doubleInputBuffer);
202 | System.out.println(1);
203 |
204 | */
205 |
206 | break;
207 | } else {
208 | // If an unknown chunk ID is found, just skip over the chunk data
209 | wavFile.iStream.skip(numChunkBytes);
210 | }
211 | }
212 |
213 | // Throw an exception if no data chunk has been found
214 | if (foundData == false) throw new WavFileException("Did not find a data chunk");
215 |
216 | // Calculate the scaling factor for converting to a normalised double
217 | if (wavFile.validBits > 8) {
218 | // If more than 8 validBits, data is signed
219 | // Conversion required dividing by magnitude of max negative value
220 | wavFile.floatOffset = 0;
221 | wavFile.floatScale = 1 << (wavFile.validBits - 1);
222 | } else {
223 | // Else if 8 or less validBits, data is unsigned
224 | // Conversion required dividing by max positive value
225 | wavFile.floatOffset = -1;
226 | wavFile.floatScale = 0.5f * ((1 << wavFile.validBits) - 1);
227 | }
228 |
229 | wavFile.bufferPointer = 0;
230 | wavFile.bytesRead = 0;
231 | wavFile.frameCounter = 0;
232 | wavFile.ioState = IOState.READING;
233 |
234 | return wavFile;
235 | }
236 |
237 | private static long getLE(byte[] buffer, int pos, int numBytes) {
238 | numBytes--;
239 | pos += numBytes;
240 |
241 | long val = buffer[pos] & 0xFF;
242 | for (int b = 0; b < numBytes; b++) val = (val << 8) + (buffer[--pos] & 0xFF);
243 |
244 | return val;
245 | }
246 |
247 | private double readSample() throws IOException, WavFileException {
248 | long val = 0;
249 |
250 | for (int b = 0; b < bytesPerSample; b++) {
251 | if (bufferPointer == bytesRead) {
252 | int read = iStream.read(buffer, 0, BUFFER_SIZE);
253 | if (read == -1) throw new WavFileException("Not enough data available");
254 | bytesRead = read;
255 | bufferPointer = 0;
256 | }
257 |
258 | int v = buffer[bufferPointer];
259 | if (b < bytesPerSample - 1 || bytesPerSample == 1) v &= 0xFF;
260 | val += v << (b * 8);
261 |
262 | bufferPointer++;
263 | }
264 |
265 | return val/32767.0;
266 | }
267 |
268 | public int readFrames(float[] sampleBuffer, int numFramesToRead) throws IOException, WavFileException {
269 | return readFramesInternal(sampleBuffer, 0, numFramesToRead);
270 | }
271 |
272 | private int readFramesInternal(float[] sampleBuffer, int offset, int numFramesToRead) throws IOException, WavFileException {
273 | if (ioState != IOState.READING) throw new IOException("Cannot read from WavFile instance");
274 |
275 | for (int f = 0; f < numFramesToRead; f++) {
276 | if (frameCounter == numFrames) return f;
277 |
278 | for (int c = 0; c < numChannels; c++) {
279 | sampleBuffer[offset] = floatOffset + (float) readSample() / floatScale;
280 | offset++;
281 | }
282 |
283 | frameCounter++;
284 | }
285 |
286 | return numFramesToRead;
287 | }
288 |
289 | public int readFrames(double[][] sampleBuffer, int numFramesToRead, int frameOffset) throws IOException, WavFileException {
290 | return readFramesInternal(sampleBuffer, frameOffset, numFramesToRead);
291 | }
292 |
293 | private int readFramesInternal(double[][] sampleBuffer, int frameOffset, int numFramesToRead) throws IOException, WavFileException {
294 | if (ioState != IOState.READING) throw new IOException("Cannot read from WavFile instance");
295 |
296 | for (int f = 0; f < numFramesToRead; f++) {
297 | if (frameCounter == numFrames) return frameOffset;
298 |
299 | for (int c = 0; c < numChannels; c++) {
300 | sampleBuffer[c][frameOffset] = (double) readSample();
301 |
302 | }
303 | frameCounter++;
304 | frameOffset++;
305 |
306 | }
307 |
308 | return frameOffset;
309 | }
310 |
311 | public void close() throws IOException {
312 | // Close the input stream and set to null
313 | if (iStream != null) {
314 | iStream.close();
315 | iStream = null;
316 | }
317 |
318 | if (oStream != null) {
319 | // Write out anything still in the local buffer
320 | if (bufferPointer > 0) oStream.write(buffer, 0, bufferPointer);
321 |
322 | // If an extra byte is required for word alignment, add it to the end
323 | if (wordAlignAdjust) oStream.write(0);
324 |
325 | // Close the stream and set to null
326 | oStream.close();
327 | oStream = null;
328 | }
329 |
330 | // Flag that the stream is closed
331 | ioState = IOState.CLOSED;
332 | }
333 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/tensorflow/android/audio/features/WavFileException.java:
--------------------------------------------------------------------------------
1 | package com.tensorflow.android.audio.features;
2 |
3 | public class WavFileException extends Exception {
4 |
5 | public WavFileException(final String message) {
6 | super(message);
7 | }
8 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/tensorflow/android/noiseclassifier/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.tensorflow.android.noiseclassifier
2 |
3 | import android.os.Bundle
4 | import android.os.Environment
5 | import android.text.TextUtils
6 | import android.util.Log
7 | import android.view.View
8 | import android.widget.ArrayAdapter
9 | import android.widget.Spinner
10 | import android.widget.Toast
11 | import androidx.appcompat.app.AppCompatActivity
12 | import com.ml.quaterion.noiseClassification.Recognition
13 | import com.tensorflow.android.audio.features.MFCC
14 | import com.tensorflow.android.audio.features.WavFile
15 | import com.tensorflow.android.audio.features.WavFileException
16 | import com.tensorflow.android.noiseclassifier.R
17 | import kotlinx.android.synthetic.main.activity_main.*
18 | import org.tensorflow.lite.DataType
19 | import org.tensorflow.lite.Interpreter
20 | import org.tensorflow.lite.support.common.FileUtil
21 | import org.tensorflow.lite.support.common.TensorProcessor
22 | import org.tensorflow.lite.support.common.ops.NormalizeOp
23 | import org.tensorflow.lite.support.label.TensorLabel
24 | import org.tensorflow.lite.support.tensorbuffer.TensorBuffer
25 | import java.io.File
26 | import java.io.IOException
27 | import java.math.RoundingMode
28 | import java.nio.ByteBuffer
29 | import java.nio.MappedByteBuffer
30 | import java.text.DecimalFormat
31 | import java.util.*
32 | import kotlin.collections.ArrayList
33 |
34 |
35 | class MainActivity : AppCompatActivity() {
36 |
37 |
38 | override fun onCreate(savedInstanceState: Bundle?) {
39 | super.onCreate(savedInstanceState)
40 | setContentView(R.layout.activity_main)
41 |
42 |
43 | // val languages = resources.getStringArray(R.array.Languages)
44 | val externalStorage: File = Environment.getExternalStorageDirectory()
45 |
46 | val audioDirPath = externalStorage.absolutePath + "/audioData";
47 |
48 | val fileNames: MutableList = ArrayList()
49 |
50 |
51 | File(audioDirPath).walk().forEach{
52 |
53 | if(it.absolutePath.endsWith(".wav")){
54 | fileNames.add(it.name)
55 | }
56 |
57 | }
58 |
59 | // access the spinner
60 | val spinner = findViewById(R.id.spinner)
61 | if (spinner != null) {
62 | val adapter = ArrayAdapter(this,
63 | android.R.layout.simple_spinner_item, fileNames)
64 | spinner.adapter = adapter
65 |
66 | }
67 |
68 |
69 |
70 | classify_button.setOnClickListener( View.OnClickListener {
71 | val selFilePath = spinner.selectedItem.toString()
72 | var audioFilePath = audioDirPath + '/' + selFilePath;
73 | if ( !TextUtils.isEmpty( selFilePath ) ){
74 |
75 |
76 | val result = classifyNoise(audioFilePath)
77 | result_text.text = "Predicted Noise : $result"
78 | }
79 | else{
80 | Toast.makeText( this@MainActivity, "Please enter a message.", Toast.LENGTH_LONG).show();
81 | }
82 | })
83 |
84 | }
85 |
86 |
87 | fun classifyNoise ( audioFilePath: String ): String? {
88 |
89 | val mNumFrames: Int
90 | val mSampleRate: Int
91 | val mChannels: Int
92 | var meanMFCCValues : FloatArray = FloatArray(1)
93 |
94 | var predictedResult: String? = "Unknown"
95 |
96 | var wavFile: WavFile? = null
97 | try {
98 | wavFile = WavFile.openWavFile(File(audioFilePath))
99 | mNumFrames = wavFile.numFrames.toInt()
100 | mSampleRate = wavFile.sampleRate.toInt()
101 | mChannels = wavFile.numChannels
102 | val buffer =
103 | Array(mChannels) { DoubleArray(mNumFrames) }
104 |
105 | var frameOffset = 0
106 | val loopCounter: Int = mNumFrames * mChannels / 4096 + 1
107 | for (i in 0 until loopCounter) {
108 | frameOffset = wavFile.readFrames(buffer, mNumFrames, frameOffset)
109 | }
110 |
111 | //trimming the magnitude values to 5 decimal digits
112 | val df = DecimalFormat("#.#####")
113 | df.setRoundingMode(RoundingMode.CEILING)
114 | val meanBuffer = DoubleArray(mNumFrames)
115 | for (q in 0 until mNumFrames) {
116 | var frameVal = 0.0
117 | for (p in 0 until mChannels) {
118 | frameVal = frameVal + buffer[p][q]
119 | }
120 | meanBuffer[q] = df.format(frameVal / mChannels).toDouble()
121 | }
122 |
123 |
124 | //MFCC java library.
125 | val mfccConvert = MFCC()
126 | mfccConvert.setSampleRate(mSampleRate)
127 | val nMFCC = 40
128 | mfccConvert.setN_mfcc(nMFCC)
129 | val mfccInput = mfccConvert.process(meanBuffer)
130 | val nFFT = mfccInput.size / nMFCC
131 | val mfccValues =
132 | Array(nMFCC) { DoubleArray(nFFT) }
133 |
134 | //loop to convert the mfcc values into multi-dimensional array
135 | for (i in 0 until nFFT) {
136 | var indexCounter = i * nMFCC
137 | val rowIndexValue = i % nFFT
138 | for (j in 0 until nMFCC) {
139 | mfccValues[j][rowIndexValue] = mfccInput[indexCounter].toDouble()
140 | indexCounter++
141 | }
142 | }
143 |
144 | //code to take the mean of mfcc values across the rows such that
145 | //[nMFCC x nFFT] matrix would be converted into
146 | //[nMFCC x 1] dimension - which would act as an input to tflite model
147 | meanMFCCValues = FloatArray(nMFCC)
148 | for (p in 0 until nMFCC) {
149 | var fftValAcrossRow = 0.0
150 | for (q in 0 until nFFT) {
151 | fftValAcrossRow = fftValAcrossRow + mfccValues[p][q]
152 | }
153 | val fftMeanValAcrossRow = fftValAcrossRow / nFFT
154 | meanMFCCValues[p] = fftMeanValAcrossRow.toFloat()
155 | }
156 |
157 |
158 | } catch (e: IOException) {
159 | e.printStackTrace()
160 | } catch (e: WavFileException) {
161 | e.printStackTrace()
162 | }
163 |
164 | predictedResult = loadModelAndMakePredictions(meanMFCCValues)
165 |
166 | return predictedResult
167 |
168 | }
169 |
170 |
171 | protected fun loadModelAndMakePredictions(meanMFCCValues : FloatArray) : String? {
172 |
173 | var predictedResult: String? = "unknown"
174 |
175 | //load the TFLite model in 'MappedByteBuffer' format using TF Interpreter
176 | val tfliteModel: MappedByteBuffer =
177 | FileUtil.loadMappedFile(this, getModelPath())
178 | val tflite: Interpreter
179 |
180 | /** Options for configuring the Interpreter. */
181 | val tfliteOptions =
182 | Interpreter.Options()
183 | tfliteOptions.setNumThreads(2)
184 | tflite = Interpreter(tfliteModel, tfliteOptions)
185 |
186 | //obtain the input and output tensor size required by the model
187 | //for urban sound classification, input tensor should be of 1x40x1x1 shape
188 | val imageTensorIndex = 0
189 | val imageShape =
190 | tflite.getInputTensor(imageTensorIndex).shape()
191 | val imageDataType: DataType = tflite.getInputTensor(imageTensorIndex).dataType()
192 | val probabilityTensorIndex = 0
193 | val probabilityShape =
194 | tflite.getOutputTensor(probabilityTensorIndex).shape()
195 | val probabilityDataType: DataType =
196 | tflite.getOutputTensor(probabilityTensorIndex).dataType()
197 |
198 | //need to transform the MFCC 1d float buffer into 1x40x1x1 dimension tensor using TensorBuffer
199 | val inBuffer: TensorBuffer = TensorBuffer.createDynamic(imageDataType)
200 | inBuffer.loadArray(meanMFCCValues, imageShape)
201 | val inpBuffer: ByteBuffer = inBuffer.getBuffer()
202 | val outputTensorBuffer: TensorBuffer =
203 | TensorBuffer.createFixedSize(probabilityShape, probabilityDataType)
204 | //run the predictions with input and output buffer tensors to get probability values across the labels
205 | tflite.run(inpBuffer, outputTensorBuffer.getBuffer())
206 |
207 |
208 | //Code to transform the probability predictions into label values
209 | val ASSOCIATED_AXIS_LABELS = "labels.txt"
210 | var associatedAxisLabels: List? = null
211 | try {
212 | associatedAxisLabels = FileUtil.loadLabels(this, ASSOCIATED_AXIS_LABELS)
213 | } catch (e: IOException) {
214 | Log.e("tfliteSupport", "Error reading label file", e)
215 | }
216 |
217 | //Tensor processor for processing the probability values and to sort them based on the descending order of probabilities
218 | val probabilityProcessor: TensorProcessor = TensorProcessor.Builder()
219 | .add(NormalizeOp(0.0f, 255.0f)).build()
220 | if (null != associatedAxisLabels) {
221 | // Map of labels and their corresponding probability
222 | val labels = TensorLabel(
223 | associatedAxisLabels,
224 | probabilityProcessor.process(outputTensorBuffer)
225 | )
226 |
227 | // Create a map to access the result based on label
228 | val floatMap: Map =
229 | labels.getMapWithFloatValue()
230 |
231 | //function to retrieve the top K probability values, in this case 'k' value is 1.
232 | //retrieved values are storied in 'Recognition' object with label details.
233 | val resultPrediction: List? = getTopKProbability(floatMap);
234 |
235 | //get the top 1 prediction from the retrieved list of top predictions
236 | predictedResult = getPredictedValue(resultPrediction)
237 |
238 | }
239 | return predictedResult
240 |
241 | }
242 |
243 |
244 | fun getPredictedValue(predictedList:List?): String?{
245 | val top1PredictedValue : Recognition? = predictedList?.get(0)
246 | return top1PredictedValue?.getTitle()
247 | }
248 |
249 | fun getModelPath(): String {
250 | // you can download this file from
251 | // see build.gradle for where to obtain this file. It should be auto
252 | // downloaded into assets.
253 | return "model.tflite"
254 | }
255 |
256 | /** Gets the top-k results. */
257 | protected fun getTopKProbability(labelProb: Map): List? {
258 | // Find the best classifications.
259 | val MAX_RESULTS: Int = 1
260 | val pq: PriorityQueue = PriorityQueue(
261 | MAX_RESULTS,
262 | Comparator { lhs, rhs -> // Intentionally reversed to put high confidence at the head of the queue.
263 | java.lang.Float.compare(rhs.getConfidence(), lhs.getConfidence())
264 | })
265 | for (entry in labelProb.entries) {
266 | pq.add(Recognition("" + entry.key, entry.key, entry.value))
267 | }
268 | val recognitions: ArrayList = ArrayList()
269 | val recognitionsSize: Int = Math.min(pq.size, MAX_RESULTS)
270 | for (i in 0 until recognitionsSize) {
271 | recognitions.add(pq.poll())
272 | }
273 | return recognitions
274 | }
275 |
276 | }
277 |
--------------------------------------------------------------------------------
/app/src/main/java/com/tensorflow/android/noiseclassifier/Recognition.kt:
--------------------------------------------------------------------------------
1 | package com.ml.quaterion.noiseClassification
2 |
3 |
4 | class Recognition {
5 |
6 |
7 | private var id : String? = null
8 | private var title : String? = null
9 | private var confidence : Float
10 |
11 | constructor(id: String, title: String, confidence: Float){
12 |
13 | this.id = id
14 | this.title = title
15 | this.confidence = confidence
16 | }
17 |
18 | fun getId(): String? {
19 | return id
20 | }
21 |
22 | fun getTitle(): String? {
23 | return title
24 | }
25 |
26 | fun getConfidence(): Float {
27 | return confidence
28 | }
29 |
30 |
31 | }
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
15 |
18 |
21 |
22 |
23 |
24 |
30 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
17 |
24 |
25 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VVasanth/Android_Tensorflow_AudioClassifier/3f8f58659d16e73405214b6bb400f6c156cab2a9/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VVasanth/Android_Tensorflow_AudioClassifier/3f8f58659d16e73405214b6bb400f6c156cab2a9/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VVasanth/Android_Tensorflow_AudioClassifier/3f8f58659d16e73405214b6bb400f6c156cab2a9/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VVasanth/Android_Tensorflow_AudioClassifier/3f8f58659d16e73405214b6bb400f6c156cab2a9/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VVasanth/Android_Tensorflow_AudioClassifier/3f8f58659d16e73405214b6bb400f6c156cab2a9/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VVasanth/Android_Tensorflow_AudioClassifier/3f8f58659d16e73405214b6bb400f6c156cab2a9/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VVasanth/Android_Tensorflow_AudioClassifier/3f8f58659d16e73405214b6bb400f6c156cab2a9/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VVasanth/Android_Tensorflow_AudioClassifier/3f8f58659d16e73405214b6bb400f6c156cab2a9/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VVasanth/Android_Tensorflow_AudioClassifier/3f8f58659d16e73405214b6bb400f6c156cab2a9/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VVasanth/Android_Tensorflow_AudioClassifier/3f8f58659d16e73405214b6bb400f6c156cab2a9/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #6200EE
4 | #3700B3
5 | #03DAC5
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | NoiseClassifier_Android_Tensorflow
3 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/test/java/com/tensorflow/android/noiseclassifier/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.tensorflow.android.noiseclassifier
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 | buildscript {
3 | ext.kotlin_version = "1.3.72"
4 | repositories {
5 | google()
6 | jcenter()
7 | }
8 | dependencies {
9 | classpath "com.android.tools.build:gradle:4.0.0"
10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
11 |
12 | // NOTE: Do not place your application dependencies here; they belong
13 | // in the individual module build.gradle files
14 | }
15 | }
16 |
17 | allprojects {
18 | repositories {
19 | google()
20 | jcenter()
21 | }
22 | }
23 |
24 | task clean(type: Delete) {
25 | delete rootProject.buildDir
26 | }
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx2048m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app"s APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Automatically convert third-party libraries to use AndroidX
19 | android.enableJetifier=true
20 | # Kotlin code style for this project: "official" or "obsolete":
21 | kotlin.code.style=official
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VVasanth/Android_Tensorflow_AudioClassifier/3f8f58659d16e73405214b6bb400f6c156cab2a9/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sat Jun 27 15:36:35 CDT 2020
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/local.properties:
--------------------------------------------------------------------------------
1 | ## This file is automatically generated by Android Studio.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file should *NOT* be checked into Version Control Systems,
5 | # as it contains information specific to your local configuration.
6 | #
7 | # Location of the SDK. This is only used by Gradle.
8 | # For customization when using a Version Control System, please read the
9 | # header note.
10 | sdk.dir=/Users/vishrud/Library/Android/sdk
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 | rootProject.name = "NoiseClassifier_Android_Tensorflow"
--------------------------------------------------------------------------------