Skip to content

opendream/vbs_recorder

Repository files navigation

VBS Recorder

VBS Recorder is an Android application for recording and managing audio files. It includes features such as splitting audio files into segments and saving them to the media store.

Installation

To install the project, follow these steps:

  1. Clone the repository:
    git clone https://github.com/yourusername/vbs_recorder.git
  2. Open the project in Android Studio.
  3. Build the project to download all dependencies.

Usage

To use the application, follow these steps:

  1. Launch the application on your Android device.
  2. Use the record button to start recording audio.
  3. The recorded audio will be split into segments and saved to the media store.

Dependencies

The project uses the following dependencies:

  • AndroidX Core KTX
  • AndroidX AppCompat
  • Material Components
  • AndroidX ConstraintLayout
  • AndroidX Navigation
  • AndroidX Activity
  • AndroidX Room
  • AWS SDK for Android (S3 and Core)
  • IIRJ (Infinite Impulse Response filters)

Add the following to your build.gradle.kts file:

dependencies {
   implementation(libs.androidx.core.ktx)
   implementation(libs.androidx.appcompat)
   implementation(libs.material)
   implementation(libs.androidx.constraintlayout)
   implementation(libs.androidx.navigation.fragment.ktx)
   implementation(libs.androidx.navigation.ui.ktx)
   implementation(libs.androidx.activity)
   implementation(libs.androidx.room.common)
   implementation(libs.androidx.room.ktx)
   implementation(libs.androidx.room.runtime)
   annotationProcessor(libs.androidx.room.compiler)
   ksp(libs.androidx.room.compiler)
   implementation(libs.aws.android.sdk.s3)
   implementation(libs.aws.android.sdk.core)
   implementation("uk.me.berndporr:iirj:1.7")
   testImplementation(libs.junit)
   androidTestImplementation(libs.androidx.junit)
   androidTestImplementation(libs.androidx.espresso.core)
}

Permissions

Ensure the following permissions are added to your AndroidManifest.xml:

<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />

<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="29" />

App Usage

  1. Recording Audio: Press the record button to start recording audio.
  2. Playing Audio: Press the play button to play the recorded audio. Use the seek bar to navigate through the audio.

Code Overview

MainActivity

Handles permission requests and basic app setup.

HomeFragment

Contains the UI and logic for recording and playing audio.

Dependencies

  • MediaRecorder for recording audio.
  • MediaPlayer for playing audio.

Setting Up and Configuring AWS S3 for vbs_recorder

Prerequisites


Steps to Set Up AWS S3

1. Create an S3 Bucket

2. Configure Bucket Permissions

3. Set Up AWS CLI

4. Upload Files to S3

  • Upload files using CLI:
    aws s3 cp /local/path s3://your-bucket-name/ --recursive
  • For detailed instructions, see Uploading Objects.

5. Integrate S3 with vbs_recorder

  • Update config.json in the repository with:
    • Bucket Name
    • AWS Region

Steps for Integration Using boto3

1. Initialize the S3 Client

Use boto3 to create an S3 client instance for interacting with AWS S3.

import boto3

s3 = boto3.client('s3')

2. Upload Recordings to S3

Use the upload_file method to upload recordings from the local system to your S3 bucket.

bucket_name = 'your-bucket-name'
file_name = 'local/path/to/recording.mp4'
s3_key = 'recordings/recording.mp4'

s3.upload_file(file_name, bucket_name, s3_key)
print(f"Uploaded {file_name} to {bucket_name}/{s3_key}")

For more details, refer to the Boto3 Upload File Documentation.

3. Retrieve Recordings from S3

Download a recording from S3 to the local system using the download_file method.

download_path = 'local/path/to/save/recording.mp4'

s3.download_file(bucket_name, s3_key, download_path)
print(f"Downloaded {bucket_name}/{s3_key} to {download_path}")

More details: Download File Documentation.

4. List Recordings in S3

List all recordings in your bucket using list_objects_v2.

response = s3.list_objects_v2(Bucket=bucket_name, Prefix='recordings/')
if 'Contents' in response:
    for obj in response['Contents']:
        print(f"Found: {obj['Key']}")
else:
    print("No recordings found.")

Reference: List Objects Documentation.

5. Delete Recordings from S3

Delete a specific recording using delete_object.

s3.delete_object(Bucket=bucket_name, Key=s3_key)
print(f"Deleted {bucket_name}/{s3_key}")

Reference: Delete Object Documentation.

License

This project is licensed under GNU General Public License v3.0.

Initial development of this project was supported by BBSRC Impact Acceleration Account (IAA) awarded to the University of Cambridge under the project titled: Accelerating the adoption of wingbeat-based sensing to quantify mosquito species abundance in the tropics led by Dr. Angkana T. Huang.