use crate::audio::AudioFormat;
use crate::config::RealtimeConfig;
use crate::error::Result;
use crate::model::RealtimeModel;
use crate::session::BoxedSession;
use async_trait::async_trait;
use super::session::{GeminiLiveBackend, GeminiRealtimeSession};
use super::{DEFAULT_MODEL, GEMINI_VOICES};
#[derive(Debug, Clone)]
pub struct GeminiRealtimeModel {
backend: GeminiLiveBackend,
model_id: String,
}
impl GeminiRealtimeModel {
pub fn new(backend: GeminiLiveBackend, model_id: impl Into<String>) -> Self {
Self { backend, model_id: model_id.into() }
}
pub fn with_default_model(backend: GeminiLiveBackend) -> Self {
Self::new(backend, DEFAULT_MODEL)
}
}
#[async_trait]
impl RealtimeModel for GeminiRealtimeModel {
fn provider(&self) -> &str {
"gemini"
}
fn model_id(&self) -> &str {
&self.model_id
}
fn supported_input_formats(&self) -> Vec<AudioFormat> {
vec![AudioFormat::pcm16_16khz()]
}
fn supported_output_formats(&self) -> Vec<AudioFormat> {
vec![AudioFormat::pcm16_24khz()]
}
fn available_voices(&self) -> Vec<&str> {
GEMINI_VOICES.to_vec()
}
async fn connect(&self, config: RealtimeConfig) -> Result<BoxedSession> {
let session =
GeminiRealtimeSession::connect(self.backend.clone(), &self.model_id, config).await?;
Ok(Box::new(session))
}
}