├── app
├── pudcam.jks
├── src
│ ├── main
│ │ ├── java
│ │ │ ├── com
│ │ │ │ ├── navbot
│ │ │ │ │ ├── aihelper
│ │ │ │ │ │ ├── WebSocketManager.kt
│ │ │ │ │ │ ├── Config.kt
│ │ │ │ │ │ ├── desktop.ini
│ │ │ │ │ │ ├── CircleWaveView.kt
│ │ │ │ │ │ ├── test.kt
│ │ │ │ │ │ ├── test-audio
│ │ │ │ │ │ └── RealTimeActivity.kt
│ │ │ │ │ └── desktop.ini
│ │ │ │ └── desktop.ini
│ │ │ └── desktop.ini
│ │ ├── res
│ │ │ ├── values
│ │ │ │ ├── strings.xml
│ │ │ │ ├── desktop.ini
│ │ │ │ ├── ids.xml
│ │ │ │ ├── colors.xml
│ │ │ │ └── themes.xml
│ │ │ ├── raw
│ │ │ │ ├── audio.wav
│ │ │ │ ├── audio2.wav
│ │ │ │ └── desktop.ini
│ │ │ ├── drawable
│ │ │ │ ├── voice.png
│ │ │ │ ├── ic_avater.png
│ │ │ │ ├── ic_close.png
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── ic_play_arrow.png
│ │ │ │ ├── ic_play_arrow1.png
│ │ │ │ ├── chatto_bg_focused.9.png
│ │ │ │ ├── desktop.ini
│ │ │ │ ├── voice_message_bg.xml
│ │ │ │ ├── bubble_right.xml
│ │ │ │ └── bubble_left.xml
│ │ │ ├── mipmap-anydpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── desktop.ini
│ │ │ ├── desktop.ini
│ │ │ ├── xml
│ │ │ │ ├── desktop.ini
│ │ │ │ ├── backup_rules.xml
│ │ │ │ └── data_extraction_rules.xml
│ │ │ └── layout
│ │ │ │ ├── desktop.ini
│ │ │ │ ├── activity_new.xml
│ │ │ │ ├── activity_main.xml
│ │ │ │ └── item_audio_message.xml
│ │ ├── desktop.ini
│ │ └── AndroidManifest.xml
│ ├── desktop.ini
│ ├── test
│ │ ├── desktop.ini
│ │ └── java
│ │ │ ├── desktop.ini
│ │ │ └── com
│ │ │ ├── desktop.ini
│ │ │ └── navbot
│ │ │ ├── desktop.ini
│ │ │ └── aihelper
│ │ │ ├── desktop.ini
│ │ │ └── ExampleUnitTest.kt
│ └── androidTest
│ │ ├── desktop.ini
│ │ └── java
│ │ ├── desktop.ini
│ │ └── com
│ │ ├── desktop.ini
│ │ └── navbot
│ │ ├── desktop.ini
│ │ └── aihelper
│ │ ├── desktop.ini
│ │ └── ExampleInstrumentedTest.kt
├── libs
│ ├── TarsosDSP-2.4.jar
│ └── desktop.ini
├── desktop.ini
├── proguard-rules.pro
├── CircleWaveView.kt
└── build.gradle.kts
├── keystore.properties
├── gradle
├── wrapper
│ ├── gradle-wrapper.jar
│ ├── desktop.ini
│ └── gradle-wrapper.properties
├── desktop.ini
└── libs.versions.toml
├── local.properties
├── settings.gradle.kts
├── README.md
├── gradle.properties
├── gradlew.bat
└── gradlew
/app/pudcam.jks:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fuwei007/OpenAIAndroidRealtimeDemo/HEAD/app/pudcam.jks
--------------------------------------------------------------------------------
/app/src/main/java/com/navbot/aihelper/WebSocketManager.kt:
--------------------------------------------------------------------------------
1 | package com.navbot.aihelper
2 |
3 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | AIHelper
3 |
--------------------------------------------------------------------------------
/app/libs/TarsosDSP-2.4.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fuwei007/OpenAIAndroidRealtimeDemo/HEAD/app/libs/TarsosDSP-2.4.jar
--------------------------------------------------------------------------------
/keystore.properties:
--------------------------------------------------------------------------------
1 | storePassword=pudcam123
2 | keyPassword=pudcam123
3 | keyAlias=pudcam
4 | storeFile=../app/pudcam.jks
--------------------------------------------------------------------------------
/app/src/main/res/raw/audio.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fuwei007/OpenAIAndroidRealtimeDemo/HEAD/app/src/main/res/raw/audio.wav
--------------------------------------------------------------------------------
/app/src/main/res/raw/audio2.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fuwei007/OpenAIAndroidRealtimeDemo/HEAD/app/src/main/res/raw/audio2.wav
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fuwei007/OpenAIAndroidRealtimeDemo/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/res/drawable/voice.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fuwei007/OpenAIAndroidRealtimeDemo/HEAD/app/src/main/res/drawable/voice.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_avater.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fuwei007/OpenAIAndroidRealtimeDemo/HEAD/app/src/main/res/drawable/ic_avater.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_close.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fuwei007/OpenAIAndroidRealtimeDemo/HEAD/app/src/main/res/drawable/ic_close.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fuwei007/OpenAIAndroidRealtimeDemo/HEAD/app/src/main/res/drawable/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_play_arrow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fuwei007/OpenAIAndroidRealtimeDemo/HEAD/app/src/main/res/drawable/ic_play_arrow.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_play_arrow1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fuwei007/OpenAIAndroidRealtimeDemo/HEAD/app/src/main/res/drawable/ic_play_arrow1.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fuwei007/OpenAIAndroidRealtimeDemo/HEAD/app/src/main/res/mipmap-anydpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/chatto_bg_focused.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fuwei007/OpenAIAndroidRealtimeDemo/HEAD/app/src/main/res/drawable/chatto_bg_focused.9.png
--------------------------------------------------------------------------------
/app/src/main/java/com/navbot/aihelper/Config.kt:
--------------------------------------------------------------------------------
1 | package com.navbot.aihelper
2 |
3 | object Config {
4 | const val OPENAI_API_KEY = "Your key"
5 | const val WSURL = "wss://api.openai.com/v1/realtime?model=gpt-4o-realtime-preview-2024-10-01"
6 | }
7 |
--------------------------------------------------------------------------------
/app/desktop.ini:
--------------------------------------------------------------------------------
1 | [ . S h e l l C l a s s I n f o ]
2 | C o n f i r m F i l e O p = 0
3 | I c o n R e s o u r c e = C : \ P r o g r a m F i l e s \ G o o g l e \ D r i v e F i l e S t r e a m \ 9 8 . 0 . 0 . 0 \ G o o g l e D r i v e F S . e x e , 2 6
4 |
--------------------------------------------------------------------------------
/app/libs/desktop.ini:
--------------------------------------------------------------------------------
1 | [ . S h e l l C l a s s I n f o ]
2 | C o n f i r m F i l e O p = 0
3 | I c o n R e s o u r c e = C : \ P r o g r a m F i l e s \ G o o g l e \ D r i v e F i l e S t r e a m \ 9 8 . 0 . 0 . 0 \ G o o g l e D r i v e F S . e x e , 2 6
4 |
--------------------------------------------------------------------------------
/app/src/desktop.ini:
--------------------------------------------------------------------------------
1 | [ . S h e l l C l a s s I n f o ]
2 | C o n f i r m F i l e O p = 0
3 | I c o n R e s o u r c e = C : \ P r o g r a m F i l e s \ G o o g l e \ D r i v e F i l e S t r e a m \ 9 8 . 0 . 0 . 0 \ G o o g l e D r i v e F S . e x e , 2 6
4 |
--------------------------------------------------------------------------------
/gradle/desktop.ini:
--------------------------------------------------------------------------------
1 | [ . S h e l l C l a s s I n f o ]
2 | C o n f i r m F i l e O p = 0
3 | I c o n R e s o u r c e = C : \ P r o g r a m F i l e s \ G o o g l e \ D r i v e F i l e S t r e a m \ 9 8 . 0 . 0 . 0 \ G o o g l e D r i v e F S . e x e , 2 6
4 |
--------------------------------------------------------------------------------
/app/src/main/desktop.ini:
--------------------------------------------------------------------------------
1 | [ . S h e l l C l a s s I n f o ]
2 | C o n f i r m F i l e O p = 0
3 | I c o n R e s o u r c e = C : \ P r o g r a m F i l e s \ G o o g l e \ D r i v e F i l e S t r e a m \ 9 8 . 0 . 0 . 0 \ G o o g l e D r i v e F S . e x e , 2 6
4 |
--------------------------------------------------------------------------------
/app/src/test/desktop.ini:
--------------------------------------------------------------------------------
1 | [ . S h e l l C l a s s I n f o ]
2 | C o n f i r m F i l e O p = 0
3 | I c o n R e s o u r c e = C : \ P r o g r a m F i l e s \ G o o g l e \ D r i v e F i l e S t r e a m \ 9 8 . 0 . 0 . 0 \ G o o g l e D r i v e F S . e x e , 2 6
4 |
--------------------------------------------------------------------------------
/gradle/wrapper/desktop.ini:
--------------------------------------------------------------------------------
1 | [ . S h e l l C l a s s I n f o ]
2 | C o n f i r m F i l e O p = 0
3 | I c o n R e s o u r c e = C : \ P r o g r a m F i l e s \ G o o g l e \ D r i v e F i l e S t r e a m \ 9 8 . 0 . 0 . 0 \ G o o g l e D r i v e F S . e x e , 2 6
4 |
--------------------------------------------------------------------------------
/app/src/androidTest/desktop.ini:
--------------------------------------------------------------------------------
1 | [ . S h e l l C l a s s I n f o ]
2 | C o n f i r m F i l e O p = 0
3 | I c o n R e s o u r c e = C : \ P r o g r a m F i l e s \ G o o g l e \ D r i v e F i l e S t r e a m \ 9 8 . 0 . 0 . 0 \ G o o g l e D r i v e F S . e x e , 2 6
4 |
--------------------------------------------------------------------------------
/app/src/main/java/desktop.ini:
--------------------------------------------------------------------------------
1 | [ . S h e l l C l a s s I n f o ]
2 | C o n f i r m F i l e O p = 0
3 | I c o n R e s o u r c e = C : \ P r o g r a m F i l e s \ G o o g l e \ D r i v e F i l e S t r e a m \ 9 8 . 0 . 0 . 0 \ G o o g l e D r i v e F S . e x e , 2 6
4 |
--------------------------------------------------------------------------------
/app/src/main/res/desktop.ini:
--------------------------------------------------------------------------------
1 | [ . S h e l l C l a s s I n f o ]
2 | C o n f i r m F i l e O p = 0
3 | I c o n R e s o u r c e = C : \ P r o g r a m F i l e s \ G o o g l e \ D r i v e F i l e S t r e a m \ 9 8 . 0 . 0 . 0 \ G o o g l e D r i v e F S . e x e , 2 6
4 |
--------------------------------------------------------------------------------
/app/src/main/res/raw/desktop.ini:
--------------------------------------------------------------------------------
1 | [ . S h e l l C l a s s I n f o ]
2 | C o n f i r m F i l e O p = 0
3 | I c o n R e s o u r c e = C : \ P r o g r a m F i l e s \ G o o g l e \ D r i v e F i l e S t r e a m \ 9 8 . 0 . 0 . 0 \ G o o g l e D r i v e F S . e x e , 2 6
4 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/desktop.ini:
--------------------------------------------------------------------------------
1 | [ . S h e l l C l a s s I n f o ]
2 | C o n f i r m F i l e O p = 0
3 | I c o n R e s o u r c e = C : \ P r o g r a m F i l e s \ G o o g l e \ D r i v e F i l e S t r e a m \ 9 8 . 0 . 0 . 0 \ G o o g l e D r i v e F S . e x e , 2 6
4 |
--------------------------------------------------------------------------------
/app/src/test/java/desktop.ini:
--------------------------------------------------------------------------------
1 | [ . S h e l l C l a s s I n f o ]
2 | C o n f i r m F i l e O p = 0
3 | I c o n R e s o u r c e = C : \ P r o g r a m F i l e s \ G o o g l e \ D r i v e F i l e S t r e a m \ 9 8 . 0 . 0 . 0 \ G o o g l e D r i v e F S . e x e , 2 6
4 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/desktop.ini:
--------------------------------------------------------------------------------
1 | [ . S h e l l C l a s s I n f o ]
2 | C o n f i r m F i l e O p = 0
3 | I c o n R e s o u r c e = C : \ P r o g r a m F i l e s \ G o o g l e \ D r i v e F i l e S t r e a m \ 9 8 . 0 . 0 . 0 \ G o o g l e D r i v e F S . e x e , 2 6
4 |
--------------------------------------------------------------------------------
/app/src/main/java/com/desktop.ini:
--------------------------------------------------------------------------------
1 | [ . S h e l l C l a s s I n f o ]
2 | C o n f i r m F i l e O p = 0
3 | I c o n R e s o u r c e = C : \ P r o g r a m F i l e s \ G o o g l e \ D r i v e F i l e S t r e a m \ 9 8 . 0 . 0 . 0 \ G o o g l e D r i v e F S . e x e , 2 6
4 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/desktop.ini:
--------------------------------------------------------------------------------
1 | [ . S h e l l C l a s s I n f o ]
2 | C o n f i r m F i l e O p = 0
3 | I c o n R e s o u r c e = C : \ P r o g r a m F i l e s \ G o o g l e \ D r i v e F i l e S t r e a m \ 9 8 . 0 . 0 . 0 \ G o o g l e D r i v e F S . e x e , 2 6
4 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/desktop.ini:
--------------------------------------------------------------------------------
1 | [ . S h e l l C l a s s I n f o ]
2 | C o n f i r m F i l e O p = 0
3 | I c o n R e s o u r c e = C : \ P r o g r a m F i l e s \ G o o g l e \ D r i v e F i l e S t r e a m \ 9 8 . 0 . 0 . 0 \ G o o g l e D r i v e F S . e x e , 2 6
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/desktop.ini:
--------------------------------------------------------------------------------
1 | [ . S h e l l C l a s s I n f o ]
2 | C o n f i r m F i l e O p = 0
3 | I c o n R e s o u r c e = C : \ P r o g r a m F i l e s \ G o o g l e \ D r i v e F i l e S t r e a m \ 9 8 . 0 . 0 . 0 \ G o o g l e D r i v e F S . e x e , 2 6
4 |
--------------------------------------------------------------------------------
/app/src/test/java/com/desktop.ini:
--------------------------------------------------------------------------------
1 | [ . S h e l l C l a s s I n f o ]
2 | C o n f i r m F i l e O p = 0
3 | I c o n R e s o u r c e = C : \ P r o g r a m F i l e s \ G o o g l e \ D r i v e F i l e S t r e a m \ 9 8 . 0 . 0 . 0 \ G o o g l e D r i v e F S . e x e , 2 6
4 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/desktop.ini:
--------------------------------------------------------------------------------
1 | [ . S h e l l C l a s s I n f o ]
2 | C o n f i r m F i l e O p = 0
3 | I c o n R e s o u r c e = C : \ P r o g r a m F i l e s \ G o o g l e \ D r i v e F i l e S t r e a m \ 9 8 . 0 . 0 . 0 \ G o o g l e D r i v e F S . e x e , 2 6
4 |
--------------------------------------------------------------------------------
/app/src/main/java/com/navbot/desktop.ini:
--------------------------------------------------------------------------------
1 | [ . S h e l l C l a s s I n f o ]
2 | C o n f i r m F i l e O p = 0
3 | I c o n R e s o u r c e = C : \ P r o g r a m F i l e s \ G o o g l e \ D r i v e F i l e S t r e a m \ 9 8 . 0 . 0 . 0 \ G o o g l e D r i v e F S . e x e , 2 6
4 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi/desktop.ini:
--------------------------------------------------------------------------------
1 | [ . S h e l l C l a s s I n f o ]
2 | C o n f i r m F i l e O p = 0
3 | I c o n R e s o u r c e = C : \ P r o g r a m F i l e s \ G o o g l e \ D r i v e F i l e S t r e a m \ 9 8 . 0 . 0 . 0 \ G o o g l e D r i v e F S . e x e , 2 6
4 |
--------------------------------------------------------------------------------
/app/src/test/java/com/navbot/desktop.ini:
--------------------------------------------------------------------------------
1 | [ . S h e l l C l a s s I n f o ]
2 | C o n f i r m F i l e O p = 0
3 | I c o n R e s o u r c e = C : \ P r o g r a m F i l e s \ G o o g l e \ D r i v e F i l e S t r e a m \ 9 8 . 0 . 0 . 0 \ G o o g l e D r i v e F S . e x e , 2 6
4 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/navbot/desktop.ini:
--------------------------------------------------------------------------------
1 | [ . S h e l l C l a s s I n f o ]
2 | C o n f i r m F i l e O p = 0
3 | I c o n R e s o u r c e = C : \ P r o g r a m F i l e s \ G o o g l e \ D r i v e F i l e S t r e a m \ 9 8 . 0 . 0 . 0 \ G o o g l e D r i v e F S . e x e , 2 6
4 |
--------------------------------------------------------------------------------
/app/src/main/java/com/navbot/aihelper/desktop.ini:
--------------------------------------------------------------------------------
1 | [ . S h e l l C l a s s I n f o ]
2 | C o n f i r m F i l e O p = 0
3 | I c o n R e s o u r c e = C : \ P r o g r a m F i l e s \ G o o g l e \ D r i v e F i l e S t r e a m \ 9 8 . 0 . 0 . 0 \ G o o g l e D r i v e F S . e x e , 2 6
4 |
--------------------------------------------------------------------------------
/app/src/test/java/com/navbot/aihelper/desktop.ini:
--------------------------------------------------------------------------------
1 | [ . S h e l l C l a s s I n f o ]
2 | C o n f i r m F i l e O p = 0
3 | I c o n R e s o u r c e = C : \ P r o g r a m F i l e s \ G o o g l e \ D r i v e F i l e S t r e a m \ 9 8 . 0 . 0 . 0 \ G o o g l e D r i v e F S . e x e , 2 6
4 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/navbot/aihelper/desktop.ini:
--------------------------------------------------------------------------------
1 | [ . S h e l l C l a s s I n f o ]
2 | C o n f i r m F i l e O p = 0
3 | I c o n R e s o u r c e = C : \ P r o g r a m F i l e s \ G o o g l e \ D r i v e F i l e S t r e a m \ 9 8 . 0 . 0 . 0 \ G o o g l e D r i v e F S . e x e , 2 6
4 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon May 20 16:35:24 CST 2024
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
5 | zipStoreBase=GRADLE_USER_HOME
6 | zipStorePath=wrapper/dists
7 | android.overridePathCheck=true
8 | android.enableJetifier=true
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/values/ids.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/local.properties:
--------------------------------------------------------------------------------
1 | ## This file must *NOT* be checked into Version Control Systems,
2 | # as it contains information specific to your local configuration.
3 | #
4 | # Location of the SDK. This is only used by Gradle.
5 | # For customization when using a Version Control System, please read the
6 | # header note.
7 | #Wed Oct 16 04:28:17 CDT 2024
8 | sdk.dir=C\:\\Users\\AdminNB001\\AppData\\Local\\Android\\Sdk
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/voice_message_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
13 |
14 |
--------------------------------------------------------------------------------
/app/src/test/java/com/navbot/aihelper/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.navbot.aihelper
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 | }
--------------------------------------------------------------------------------
/app/src/main/res/xml/backup_rules.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/data_extraction_rules.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
12 |
13 |
19 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FFBB86FC
4 | #FF6200EE
5 | #FF3700B3
6 | #FF03DAC5
7 | #FF018786
8 | #FF000000
9 | #6200EE
10 | #3700B3
11 | #03DAC5
12 | #ffffff
13 | #FF0000
14 | #FFF4F5F8
15 | #00C853
16 |
17 |
--------------------------------------------------------------------------------
/settings.gradle.kts:
--------------------------------------------------------------------------------
1 | pluginManagement {
2 | repositories {
3 | google {
4 | content {
5 | includeGroupByRegex("com\\.android.*")
6 | includeGroupByRegex("com\\.google.*")
7 | includeGroupByRegex("androidx.*")
8 | }
9 | }
10 | mavenCentral()
11 | gradlePluginPortal()
12 |
13 | maven { setUrl("https://jitpack.io") }
14 | }
15 | }
16 | dependencyResolutionManagement {
17 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
18 | repositories {
19 | google()
20 | mavenCentral()
21 |
22 | maven { setUrl("https://jitpack.io") }
23 | }
24 | }
25 |
26 | rootProject.name = "AIHelper"
27 | include(":app")
28 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/navbot/aihelper/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.navbot.aihelper
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.navbot.aihelper", appContext.packageName)
23 | }
24 | }
--------------------------------------------------------------------------------
/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/main/res/drawable/bubble_right.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
18 |
19 |
20 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bubble_left.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
18 |
19 |
20 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_new.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
15 |
16 |
23 |
24 |
25 |
26 |
27 |
36 |
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # OpenAIAndroidRealtimeDemo
2 | My First Android Kotlin Demo with OpenAI Real Time API, developer can now build AI agent quickly
3 |
4 |
5 | I noticed that most demos of OpenAI’s real-time API are either Node.js or web-based, so I decided to release the first Android demo using Kotlin. Hope you enjoy it!
6 |
7 | I’ll be creating more tutorials on AI application development in the future, so make sure to subscribe to stay updated!
8 |
9 |
10 | For the Android app, we need to carefully deal with the following items:
11 | 1) the audio collecting and processing
12 | 2) the interaction with Openai API
13 | 3) Ensuring the AI agent’s audio isn’t captured while it’s speaking
14 |
15 | Watch till the end for valuable insights and unique implementation techniques!
16 |
17 | GitHub Repo: (https://github.com/fuwei007/OpenAIAndroidRealtimeDemo)
18 |
19 | LinkedIn: https://www.linkedin.com/in/navbot-frank/
20 |
21 | X: https://x.com/fuwei007cn
22 |
23 | facebook:https://www.facebook.com/weiwei.fufu
24 |
25 |
26 | See my previous demo:
27 | Real-time API on Python: (https://www.youtube.com/watch?v=lOypO-ngBJ8&t=3s)
28 |
29 | Real-time API demo on IOS: (https://www.youtube.com/watch?v=eWsvwTnscBA&t=877s)
30 |
31 | Real-time API live demo at OpenAI'dev day: (https://www.youtube.com/watch?v=mVR90WmA34U&t=657s)
32 |
33 | Takeaways OpenAI'dev day: (https://www.youtube.com/watch?v=LIR21LcfRpM&t=64s)
34 |
35 |
36 |
--------------------------------------------------------------------------------
/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 -Dfile.encoding=UTF-8
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. For more details, visit
12 | # https://developer.android.com/r/tools/gradle-multi-project-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 | # Kotlin code style for this project: "official" or "obsolete":
19 | kotlin.code.style=official
20 | # Enables namespacing of each library's R class so that its R class includes only the
21 | # resources declared in the library itself and none from the library's dependencies,
22 | # thereby reducing the size of the R class for that library
23 | android.nonTransitiveRClass=true
24 | isDebug = true
25 | android.enableJetifier=true
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
22 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/app/src/main/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
15 |
16 |
17 |
28 |
29 |
30 |
31 |
35 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
18 |
19 |
20 |
26 |
27 |
28 |
32 |
33 |
34 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/app/CircleWaveView.kt:
--------------------------------------------------------------------------------
1 | package com.navbot.aihelper
2 |
3 | import android.content.Context
4 | import android.graphics.Canvas
5 | import android.graphics.Color
6 | import android.graphics.Paint
7 | import android.util.AttributeSet
8 | import android.view.View
9 | import kotlin.math.min
10 |
11 |
12 | class CircleWaveView @JvmOverloads constructor(
13 | context: Context, attrs: AttributeSet? = null
14 | ) : View(context, attrs) {
15 |
16 | private val circlePaint = Paint().apply {
17 | color = Color.GRAY // 灰色圆
18 | style = Paint.Style.FILL
19 | }
20 |
21 | private val fixedWidth = 100f // 固定宽度
22 | private val initialHeight = 100f // 初始高度为圆形
23 | private val maxHeight = 400f // 最大高度,讲话时的最大拉伸高度
24 |
25 | private val spacing = 120 // 圆之间的间距
26 | private var circleScales = listOf(1f, 1f, 1f, 1f) // 初始化四个圆形高度比例
27 |
28 | override fun onDraw(canvas: Canvas) {
29 | super.onDraw(canvas)
30 | val widthCenter = width / 2
31 | val heightCenter = height / 2
32 |
33 | for (i in 0..3) {
34 | val ellipseHeight = initialHeight + (maxHeight - initialHeight) * circleScales[i]
35 |
36 | // 画上下带有圆弧的竖直椭圆
37 | canvas.drawRoundRect(
38 | widthCenter.toFloat() + (i - 1.5f) * spacing - fixedWidth / 2, // 左边
39 | heightCenter - ellipseHeight / 2, // 上边
40 | widthCenter.toFloat() + (i - 1.5f) * spacing + fixedWidth / 2, // 右边
41 | heightCenter + ellipseHeight / 2, // 下边
42 | fixedWidth / 2, // x方向的圆角半径
43 | fixedWidth / 2, // y方向的圆角半径
44 | circlePaint
45 | )
46 | }
47 | }
48 |
49 | // 传入一个高度比例列表,更新四个圆的高度
50 | fun updateCircles(scaleList: List) {
51 | if (scaleList.size == 4) {
52 | circleScales = scaleList
53 | invalidate() // 重绘视图
54 | }
55 | }
56 |
57 | // 重置圆形为初始状态
58 | fun resetCircles() {
59 | circleScales = listOf(1f, 1f, 1f, 1f) // 重置为圆形
60 | invalidate()
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/app/src/main/java/com/navbot/aihelper/CircleWaveView.kt:
--------------------------------------------------------------------------------
1 | package com.navbot.aihelper
2 |
3 | import android.content.Context
4 | import android.graphics.Canvas
5 | import android.graphics.Color
6 | import android.graphics.Paint
7 | import android.util.AttributeSet
8 | import android.view.View
9 | import kotlin.math.min
10 |
11 |
12 |
13 | class CircleWaveView @JvmOverloads constructor(
14 | context: Context, attrs: AttributeSet? = null
15 | ) : View(context, attrs) {
16 |
17 | private val circlePaint = Paint().apply {
18 | color = Color.GRAY // 圆的颜色
19 | style = Paint.Style.FILL
20 | }
21 |
22 | private val fixedWidth = 150f // 固定宽度,增大圆的宽度
23 | private val initialHeight = 150f // 初始高度保证圆的比例增大
24 | private val maxHeight = 400f // 最大拉伸高度
25 |
26 | private val spacing = 170f // 增加圆之间的间距,保证圆不挤在一起
27 | private var circleScales = listOf(1f, 1f, 1f, 1f) // 初始比例为1
28 |
29 | override fun onDraw(canvas: Canvas) {
30 | super.onDraw(canvas)
31 |
32 | // 计算绘制区域的中心
33 | val widthCenter = width / 2
34 | val heightCenter = height / 2
35 |
36 | for (i in 0 until 4) {
37 | val ellipseHeight = initialHeight * circleScales[i] // 根据比例调整高度
38 |
39 | // 画上下带有圆弧的竖直椭圆
40 | canvas.drawRoundRect(
41 | widthCenter.toFloat() + (i - 1.5f) * spacing - fixedWidth / 2, // 左边
42 | heightCenter - ellipseHeight / 2, // 上边
43 | widthCenter.toFloat() + (i - 1.5f) * spacing + fixedWidth / 2, // 右边
44 | heightCenter + ellipseHeight / 2, // 下边
45 | fixedWidth / 2, // x方向的圆角半径
46 | fixedWidth / 2, // y方向的圆角半径
47 | circlePaint
48 | )
49 | }
50 | }
51 |
52 | // 传入一个高度比例列表,更新四个圆的高度
53 | fun updateCircles(scaleList: List) {
54 | if (scaleList.size == 4) {
55 | circleScales = scaleList.map { 1f + (it * 2f) } // 基于原始圆形比例进行拉伸
56 | invalidate() // 重新绘制视图
57 | }
58 | }
59 |
60 | // 重置圆形为初始状态
61 | fun resetCircles() {
62 | circleScales = listOf(1f, 1f, 1f, 1f) // 重置为标准圆形
63 | invalidate()
64 | }
65 | }
66 |
67 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%" == "" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%" == "" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34 |
35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37 |
38 | @rem Find java.exe
39 | if defined JAVA_HOME goto findJavaFromJavaHome
40 |
41 | set JAVA_EXE=java.exe
42 | %JAVA_EXE% -version >NUL 2>&1
43 | if "%ERRORLEVEL%" == "0" goto execute
44 |
45 | echo.
46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47 | echo.
48 | echo Please set the JAVA_HOME variable in your environment to match the
49 | echo location of your Java installation.
50 |
51 | goto fail
52 |
53 | :findJavaFromJavaHome
54 | set JAVA_HOME=%JAVA_HOME:"=%
55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56 |
57 | if exist "%JAVA_EXE%" goto execute
58 |
59 | echo.
60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61 | echo.
62 | echo Please set the JAVA_HOME variable in your environment to match the
63 | echo location of your Java installation.
64 |
65 | goto fail
66 |
67 | :execute
68 | @rem Setup the command line
69 |
70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71 |
72 |
73 | @rem Execute Gradle
74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75 |
76 | :end
77 | @rem End local scope for the variables with windows NT shell
78 | if "%ERRORLEVEL%"=="0" goto mainEnd
79 |
80 | :fail
81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82 | rem the _cmd.exe /c_ return code!
83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84 | exit /b 1
85 |
86 | :mainEnd
87 | if "%OS%"=="Windows_NT" endlocal
88 |
89 | :omega
90 |
--------------------------------------------------------------------------------
/gradle/libs.versions.toml:
--------------------------------------------------------------------------------
1 | [versions]
2 | agp = "8.2.0"
3 | kotlin = "1.9.0"
4 | coreKtx = "1.10.1"
5 | junit = "4.13.2"
6 | junitVersion = "1.1.5"
7 | espressoCore = "3.5.1"
8 | lifecycleRuntimeKtx = "2.6.1"
9 | activityCompose = "1.6.0"
10 | composeBom = "2023.08.00"
11 | appcompat = "1.6.1"
12 | retrofit = "2.6.0"
13 | adapter_rxjava = "2.6.0"
14 | converter_scalars = "2.6.0"
15 | lifecycle-viewmodel-compose = "1.0.0-alpha07"
16 | recyclerview = "1.2.0-alpha03"
17 | material = "1.10.0"
18 | backgroundLibrary = "1.7.6"
19 | utilcodex = "1.31.1"
20 | cameraCore = "1.3.4"
21 | cameraView = "1.3.4"
22 | cameraLifecycle = "1.3.4"
23 | okhttpVersion = "4.9.3"
24 |
25 |
26 | [libraries]
27 | androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
28 | junit = { group = "junit", name = "junit", version.ref = "junit" }
29 | androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" }
30 | androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" }
31 | androidx-lifecycle-runtime-ktx = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "lifecycleRuntimeKtx" }
32 | androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "activityCompose" }
33 | androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "composeBom" }
34 | androidx-ui = { group = "androidx.compose.ui", name = "ui" }
35 | androidx-ui-graphics = { group = "androidx.compose.ui", name = "ui-graphics" }
36 | androidx-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" }
37 | androidx-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview" }
38 | androidx-ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest" }
39 | androidx-ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4" }
40 | androidx-material3 = { group = "androidx.compose.material3", name = "material3" }
41 | retrofit = { module = "com.squareup.retrofit2:retrofit", version.ref = "retrofit" }
42 | adapter_rxjava = { module = "com.squareup.retrofit2:adapter-rxjava2", version.ref = "adapter_rxjava" }
43 | converter_scalars = { module = "com.squareup.retrofit2:converter-scalars", version.ref = "converter_scalars" }
44 | recyclerview = { module = "androidx.recyclerview:recyclerview", version.ref = "recyclerview" }
45 | androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" }
46 | material = { group = "com.google.android.material", name = "material", version.ref = "material" }
47 | utilcodex = { module = "com.blankj:utilcodex", version.ref = "utilcodex" }
48 | backgroundLibrary = { module = "com.github.JavaNoober.BackgroundLibrary:library", version.ref = "backgroundLibrary" }
49 | androidx-camera-core = { group = "androidx.camera", name = "camera-core", version.ref = "cameraCore" }
50 | androidx-camera-view = { group = "androidx.camera", name = "camera-view", version.ref = "cameraView" }
51 | androidx-camera-lifecycle = { group = "androidx.camera", name = "camera-lifecycle", version.ref = "cameraLifecycle" }
52 | okhttp3-okhttp = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttpVersion" }
53 |
54 | [plugins]
55 | android-application = { id = "com.android.application", version.ref = "agp" }
56 | jetbrains-kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
57 |
58 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_audio_message.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
18 |
19 |
26 |
34 |
35 |
36 |
37 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
55 |
56 |
63 |
64 |
65 |
66 |
74 |
75 |
79 |
80 |
81 |
89 |
90 |
91 |
92 |
93 |
94 |
101 |
102 |
103 |
104 |
105 |
106 |
--------------------------------------------------------------------------------
/app/build.gradle.kts:
--------------------------------------------------------------------------------
1 | import java.io.FileInputStream
2 | import java.util.Properties
3 |
4 | plugins {
5 | alias(libs.plugins.android.application)
6 | alias(libs.plugins.jetbrains.kotlin.android)
7 | }
8 |
9 | android {
10 | namespace = "com.navbot.aihelper"
11 | compileSdk = 34
12 |
13 | defaultConfig {
14 | applicationId = "com.navbot.aihelper"
15 | minSdk = 28
16 | targetSdk = 34
17 | versionCode = 4
18 | versionName = "1.3"
19 |
20 | testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
21 | vectorDrawables {
22 | useSupportLibrary = true
23 | }
24 |
25 | }
26 | signingConfigs {
27 |
28 |
29 | val keystorePropertiesFile = rootProject.file("keystore.properties")
30 | val keystoreProperties = Properties()
31 | keystoreProperties.load(FileInputStream(keystorePropertiesFile))
32 |
33 | create("release") {
34 | keyAlias = keystoreProperties["keyAlias"] as String
35 | keyPassword = keystoreProperties["keyPassword"] as String
36 | storeFile = file(keystoreProperties["storeFile"] as String)
37 | storePassword = keystoreProperties["storePassword"] as String
38 | }
39 | }
40 |
41 | applicationVariants.all {
42 | val variantName = this.versionName
43 | val buildType = this.buildType.name
44 | outputs.all {
45 | val output = this as com.android.build.gradle.internal.api.BaseVariantOutputImpl
46 | val appName = "Ai-Helper"
47 | val suffix = if (buildType == "release") "release" else "debug"
48 |
49 | val newApkName = "${appName}_v${variantName}-${suffix}.apk"
50 | val outputImpl = output as com.android.build.gradle.internal.api.BaseVariantOutputImpl
51 | outputImpl.outputFileName = newApkName
52 | }
53 | }
54 |
55 | buildTypes {
56 | release {
57 | isMinifyEnabled = false
58 | proguardFiles(
59 | getDefaultProguardFile("proguard-android-optimize.txt"),
60 | "proguard-rules.pro"
61 | )
62 | }
63 | }
64 | compileOptions {
65 | sourceCompatibility = JavaVersion.VERSION_1_8
66 | targetCompatibility = JavaVersion.VERSION_1_8
67 | }
68 | kotlinOptions {
69 | jvmTarget = "1.8"
70 | }
71 | buildFeatures {
72 | compose = true
73 | }
74 | composeOptions {
75 | kotlinCompilerExtensionVersion = "1.5.1"
76 | }
77 | packaging {
78 | resources {
79 | excludes += "/META-INF/{AL2.0,LGPL2.1}"
80 | }
81 | }
82 | }
83 |
84 | dependencies {
85 |
86 | implementation(libs.androidx.core.ktx)
87 | implementation(libs.androidx.appcompat)
88 | implementation(libs.androidx.lifecycle.runtime.ktx)
89 | implementation(libs.androidx.activity.compose)
90 | implementation(platform(libs.androidx.compose.bom))
91 | implementation(libs.androidx.ui)
92 | implementation(libs.androidx.ui.graphics)
93 | implementation(libs.androidx.ui.tooling.preview)
94 | implementation(libs.androidx.material3)
95 | implementation(libs.androidx.camera.core)
96 | implementation(libs.androidx.camera.view)
97 | implementation(libs.androidx.camera.lifecycle)
98 | testImplementation(libs.junit)
99 | androidTestImplementation(libs.androidx.junit)
100 | androidTestImplementation(libs.androidx.espresso.core)
101 | androidTestImplementation(platform(libs.androidx.compose.bom))
102 | androidTestImplementation(libs.androidx.ui.test.junit4)
103 | debugImplementation(libs.androidx.ui.tooling)
104 | debugImplementation(libs.androidx.ui.test.manifest)
105 | debugImplementation(libs.material)
106 |
107 |
108 | implementation("androidx.media:media:1.3.1")
109 | implementation(libs.recyclerview)
110 | implementation(libs.backgroundLibrary)
111 | implementation(libs.utilcodex)
112 | implementation(libs.material)
113 | implementation(libs.okhttp3.okhttp)
114 |
115 |
116 | implementation("androidx.collection:collection:1.1.0")
117 | implementation(files("libs/TarsosDSP-2.4.jar"))
118 |
119 | }
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | #
4 | # Copyright 2015 the original author or authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | ##############################################################################
20 | ##
21 | ## Gradle start up script for UN*X
22 | ##
23 | ##############################################################################
24 |
25 | # Attempt to set APP_HOME
26 | # Resolve links: $0 may be a link
27 | PRG="$0"
28 | # Need this for relative symlinks.
29 | while [ -h "$PRG" ] ; do
30 | ls=`ls -ld "$PRG"`
31 | link=`expr "$ls" : '.*-> \(.*\)$'`
32 | if expr "$link" : '/.*' > /dev/null; then
33 | PRG="$link"
34 | else
35 | PRG=`dirname "$PRG"`"/$link"
36 | fi
37 | done
38 | SAVED="`pwd`"
39 | cd "`dirname \"$PRG\"`/" >/dev/null
40 | APP_HOME="`pwd -P`"
41 | cd "$SAVED" >/dev/null
42 |
43 | APP_NAME="Gradle"
44 | APP_BASE_NAME=`basename "$0"`
45 |
46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
48 |
49 | # Use the maximum available, or set MAX_FD != -1 to use that value.
50 | MAX_FD="maximum"
51 |
52 | warn () {
53 | echo "$*"
54 | }
55 |
56 | die () {
57 | echo
58 | echo "$*"
59 | echo
60 | exit 1
61 | }
62 |
63 | # OS specific support (must be 'true' or 'false').
64 | cygwin=false
65 | msys=false
66 | darwin=false
67 | nonstop=false
68 | case "`uname`" in
69 | CYGWIN* )
70 | cygwin=true
71 | ;;
72 | Darwin* )
73 | darwin=true
74 | ;;
75 | MINGW* )
76 | msys=true
77 | ;;
78 | NONSTOP* )
79 | nonstop=true
80 | ;;
81 | esac
82 |
83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
84 |
85 |
86 | # Determine the Java command to use to start the JVM.
87 | if [ -n "$JAVA_HOME" ] ; then
88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
89 | # IBM's JDK on AIX uses strange locations for the executables
90 | JAVACMD="$JAVA_HOME/jre/sh/java"
91 | else
92 | JAVACMD="$JAVA_HOME/bin/java"
93 | fi
94 | if [ ! -x "$JAVACMD" ] ; then
95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
96 |
97 | Please set the JAVA_HOME variable in your environment to match the
98 | location of your Java installation."
99 | fi
100 | else
101 | JAVACMD="java"
102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
103 |
104 | Please set the JAVA_HOME variable in your environment to match the
105 | location of your Java installation."
106 | fi
107 |
108 | # Increase the maximum file descriptors if we can.
109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
110 | MAX_FD_LIMIT=`ulimit -H -n`
111 | if [ $? -eq 0 ] ; then
112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
113 | MAX_FD="$MAX_FD_LIMIT"
114 | fi
115 | ulimit -n $MAX_FD
116 | if [ $? -ne 0 ] ; then
117 | warn "Could not set maximum file descriptor limit: $MAX_FD"
118 | fi
119 | else
120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
121 | fi
122 | fi
123 |
124 | # For Darwin, add options to specify how the application appears in the dock
125 | if $darwin; then
126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
127 | fi
128 |
129 | # For Cygwin or MSYS, switch paths to Windows format before running java
130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
133 |
134 | JAVACMD=`cygpath --unix "$JAVACMD"`
135 |
136 | # We build the pattern for arguments to be converted via cygpath
137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
138 | SEP=""
139 | for dir in $ROOTDIRSRAW ; do
140 | ROOTDIRS="$ROOTDIRS$SEP$dir"
141 | SEP="|"
142 | done
143 | OURCYGPATTERN="(^($ROOTDIRS))"
144 | # Add a user-defined pattern to the cygpath arguments
145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
147 | fi
148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
149 | i=0
150 | for arg in "$@" ; do
151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
153 |
154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
156 | else
157 | eval `echo args$i`="\"$arg\""
158 | fi
159 | i=`expr $i + 1`
160 | done
161 | case $i in
162 | 0) set -- ;;
163 | 1) set -- "$args0" ;;
164 | 2) set -- "$args0" "$args1" ;;
165 | 3) set -- "$args0" "$args1" "$args2" ;;
166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
172 | esac
173 | fi
174 |
175 | # Escape application args
176 | save () {
177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
178 | echo " "
179 | }
180 | APP_ARGS=`save "$@"`
181 |
182 | # Collect all arguments for the java command, following the shell quoting and substitution rules
183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
184 |
185 | exec "$JAVACMD" "$@"
186 |
--------------------------------------------------------------------------------
/app/src/main/java/com/navbot/aihelper/test.kt:
--------------------------------------------------------------------------------
1 | //package com.navbot.aihelper
2 | //
3 | //import android.Manifest
4 | //import android.annotation.SuppressLint
5 | //import android.content.pm.PackageManager
6 | //import android.media.AudioFormat
7 | //import android.media.AudioManager
8 | //import android.media.AudioRecord
9 | //import android.media.AudioTrack
10 | //import android.media.MediaRecorder
11 | //import android.os.Bundle
12 | //import android.util.Base64
13 | //import android.util.Log
14 | //import android.widget.Button
15 | //import androidx.appcompat.app.AppCompatActivity
16 | //import androidx.core.app.ActivityCompat
17 | //import be.tarsos.dsp.AudioDispatcher
18 | //import be.tarsos.dsp.AudioEvent
19 | //import be.tarsos.dsp.AudioProcessor
20 | //import be.tarsos.dsp.io.android.AudioDispatcherFactory
21 | //import com.blankj.utilcode.util.ToastUtils
22 | //import kotlinx.coroutines.CoroutineScope
23 | //import kotlinx.coroutines.Dispatchers
24 | //import kotlinx.coroutines.launch
25 | //import kotlinx.coroutines.withContext
26 | //import okhttp3.OkHttpClient
27 | //import okhttp3.Request
28 | //import okhttp3.WebSocket
29 | //import okhttp3.WebSocketListener
30 | //import org.json.JSONObject
31 | //import java.io.ByteArrayOutputStream
32 | //import java.io.File
33 | //import java.io.FileInputStream
34 | //import java.nio.ByteBuffer
35 | //import java.nio.ByteOrder
36 | //import java.util.LinkedList
37 | //import java.util.concurrent.Executors
38 | //
39 | //class NewActivity : AppCompatActivity() {
40 | //
41 | // private val TAG = "AudioRMS"
42 | // private lateinit var webSocket: WebSocket
43 | // private var dispatcher: AudioDispatcher? = null
44 | // private val permissions = arrayOf(Manifest.permission.RECORD_AUDIO)
45 | // private var canRecord = false
46 | // private val bufferSize = 4096 // Buffer size for audio chunks
47 | // private val WSURL = "wss://api.openai.com/v1/realtime?model=gpt-4o-realtime-preview-2024-10-01"
48 | // private val Authorization = ""
49 | // private val CHUNK_SIZE = 100 // Chunk size in milliseconds for sending audio data
50 | // private val IS_DEBUG = false
51 | //
52 | // override fun onCreate(savedInstanceState: Bundle?) {
53 | // super.onCreate(savedInstanceState)
54 | // setContentView(R.layout.activity_new)
55 | // ActivityCompat.requestPermissions(this, permissions, 200)
56 | //
57 | // findViewById