Intermediate: Edit, Extract and Convert Audio using Huawei Audio Editor Kit in Android
Introduction
As we listen Audio edit and extract implementation in Android, we think it will take long time to implement these features and it requires lot of coding experience. But Huawei Audio Editor Kit reduces and smoothen our efforts to implement these features. Huawei Audio Editor Kit provides features like editing, extracting and converting audio in one kit. We can edit audio and set style (like Bass boost), adjusting pitch and sound tracks. It also provides the recording feature and we can export the audio file to the directory. We can convert audio to different formats like MP3, WAV, M4A and AAC and also extract audio from video like MP4.
Let us start with the project configuration part:
Step 1: Configure App Information in App Gallery Connect.
Step 2: Integrate HMS Core SDK.
Step 3: Add permission to Android Manifest.
Step 4: Sync the project.
Let us start with the implementation part:
Step 1: Add runtime permission to MainActivity.java onCreate() method.
Step 2: Create activity_main.xml for buttons.
Step 3: Create MainActivity.java for implementing click listener for buttons.
Step 4: Launch the Audio Editor present inside sdk after clicking on Edit Audio.
Convert Audio Implementation
Step 5: Create format_audio.xml for the UI.
Step 6: Create FormatAudioActivity.java and choose the audio file inside onCreate() method.
Step 7: Create the destination audio path for saving the file.
Step 8: Convert the audio file to the selected format.
FormatAudioActivity.java
Extract Audio from Video
Step 9: Create the extract_audio.xml for UI.
Step 10: Create ExtractAudioActivity.java and choose the video file inside onCreate() method.
Step 11: Create the destination path for saving the video file.
Step 12: Extract the audio from video.
ExtractAudioActivity.java
Now implementation part done.
Result
Tips and Tricks
- Add compile options to app level build.gradle file.
2. Add requestLegacyExternalStorage to true inside application tag in AndroidManifest.xml for creating directory.
3. It supports Huawei (EMUI 5.0 or later) and Non Huawei Phone (5.0 or later) both.
4. It supports audio file conversion into MP3, WAV, AAC and M4A.
5. All API’s of Audio Editor Kit is free of charge.
Conclusion
In this article, We have learnt about editing the audio with styles, pitch and Bass. We can also convert audio into different file formats and extract audio from video.
Thanks for reading! If you enjoyed this story, please provide Likes and Comments.
Reference