mirror of
https://github.com/perstarkse/minne.git
synced 2026-07-02 19:11:43 +02:00
feat: handles submitted audio
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
use async_openai::types::{CreateTranscriptionRequestArgs, AudioResponseFormat};
|
||||
use common::{
|
||||
error::AppError,
|
||||
storage::{
|
||||
db::SurrealDbClient,
|
||||
types::system_settings::SystemSettings,
|
||||
},
|
||||
};
|
||||
|
||||
/// Transcribes an audio file using the configured OpenAI Whisper model.
|
||||
pub async fn transcribe_audio_file(
|
||||
file_path: &str,
|
||||
db_client: &SurrealDbClient,
|
||||
openai_client: &async_openai::Client<async_openai::config::OpenAIConfig>,
|
||||
) -> Result<String, AppError> {
|
||||
let system_settings = SystemSettings::get_current(db_client).await?;
|
||||
let model = system_settings.voice_processing_model;
|
||||
|
||||
let request = CreateTranscriptionRequestArgs::default()
|
||||
.file(file_path)
|
||||
.model(model)
|
||||
.response_format(AudioResponseFormat::Json)
|
||||
.build()?;
|
||||
|
||||
let response = openai_client
|
||||
.audio()
|
||||
.transcribe(request)
|
||||
.await
|
||||
.map_err(|e| AppError::Processing(format!("Audio transcription failed: {}", e)))?;
|
||||
Ok(response.text)
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
pub mod image_parsing;
|
||||
pub mod llm_instructions;
|
||||
pub mod audio_transcription;
|
||||
|
||||
use common::error::AppError;
|
||||
use std::collections::HashMap;
|
||||
|
||||
Reference in New Issue
Block a user