whisper_android
1.0.0
이 안내서는 오디오 녹음 및 음성 인식을 위해 Android 앱에서 Whisper and Recorder 클래스를 통합하는 방법을 설명합니다.
다음은 Whisper
및 Recorder
사용하기위한 별도의 코드 스 니펫입니다.
초기화 및 구성 :
// Initialize Whisper
Whisper mWhisper = new Whisper ( this ); // Create Whisper instance
// Load model and vocabulary for Whisper
String modelPath = getFilePath ( "whisper-tiny.tflite" ); // Provide model file path
String vocabPath = getFilePath ( "filters_vocab_multilingual.bin" ); // Provide vocabulary file path
mWhisper . loadModel ( modelPath , vocabPath , true ); // Load model and set multilingual mode
// Set a listener for Whisper to handle updates and results
mWhisper . setListener ( new IWhisperListener () {
@ Override
public void onUpdateReceived ( String message ) {
// Handle Whisper status updates
}
@ Override
public void onResultReceived ( String result ) {
// Handle transcribed results
}
});
전사:
// Set the audio file path for transcription. Audio format should be in 16K, mono, 16bits
String waveFilePath = getFilePath ( "your_audio_file.wav" ); // Provide audio file path
mWhisper . setFilePath ( waveFilePath ); // Set audio file path
// Start transcription
mWhisper . setAction ( Whisper . ACTION_TRANSCRIBE ); // Set action to transcription
mWhisper . start (); // Start transcription
// Perform other operations
// Add your additional code here
// Stop transcription
mWhisper . stop (); // Stop transcription
초기화 및 구성 :
// Initialize Recorder
Recorder mRecorder = new Recorder ( this ); // Create Recorder instance
// Set a listener for Recorder to handle updates and audio data
mRecorder . setListener ( new IRecorderListener () {
@ Override
public void onUpdateReceived ( String message ) {
// Handle Recorder status updates
}
@ Override
public void onDataReceived ( float [] samples ) {
// Handle audio data received during recording
// You can forward this data to Whisper for live recognition using writeBuffer()
// mWhisper.writeBuffer(samples);
}
});
녹음:
// Check and request recording permissions
checkRecordPermission (); // Check and request recording permissions
// Set the audio file path for recording. It record audio in 16K, mono, 16bits format
String waveFilePath = getFilePath ( "your_audio_file.wav" ); // Provide audio file path
mRecorder . setFilePath ( waveFilePath ); // Set audio file path
// Start recording
mRecorder . start (); // Start recording
// Perform other operations
// Add your additional code here
// Stop recording
mRecorder . stop (); // Stop recording
이 코드 스 니펫을 특정 사용 사례에 조정하고 올바른 파일 경로를 제공하며 응용 프로그램에서 예외를 적절하게 처리하십시오.
참고 : Recorder
클래스를 사용할 때 응용 프로그램에 필요한 권한, 오류 처리 및 파일 경로 관리가 있는지 확인하십시오.
Whisper ASR은 음성을 텍스트로 전사하기위한 강력한 도구입니다. 그러나 오디오 데이터 및 전사를 처리하려면 Android 애플리케이션에서 원활한 사용자 경험을 보장하기 위해 신중한 동기화 및 오류 처리가 필요할 수 있습니다.
Whisper ASR Android 앱을 사용하여 음성 인식 기능을 향상 시키십시오!