Concatenate audio files and silence periods into a single audio file for React Native.
- ✅ Concat multiple audio files with silence periods
- ✅ Support for iOS and Android
- ✅ Output in M4A format
npm install react-native-audio-concat
cd ios && pod install
No additional steps required.
import { concatAudioFiles } from 'react-native-audio-concat';
// Concatenate audio files with silence periods
const data = [
{ filePath: '/path/to/audio1.m4a' },
{ durationMs: 500 }, // 500ms silence
{ filePath: '/path/to/audio2.m4a' },
{ durationMs: 1000 }, // 1 second silence
{ filePath: '/path/to/audio3.m4a' },
];
const outputPath = '/path/to/merged.m4a';
try {
const result = await concatAudioFiles(data, outputPath);
console.log('Concatenated audio file:', result);
} catch (error) {
console.error('Failed to concatenate audio:', error);
}
Concatenates audio files and silence periods into a single output file.
Parameters:
data
:AudioDataOrSilence[]
- Array of audio files and silence periods to merge. Each item can be either:{ filePath: string }
- Path to an audio file{ durationMs: number }
- Duration of silence in milliseconds
outputPath
:string
- Absolute path where the merged audio file will be saved (M4A format)
Returns:
Promise<string>
- Resolves with the output file path
Check out the example app for a complete working example.
MIT
Made with create-react-native-library