subx_cli/services/audio/
aus_adapter.rs1use crate::{Result, error::SubXError};
4use aus::AudioFile;
5use std::path::Path;
6
7pub struct AusAdapter {
9 sample_rate: u32,
10}
11
12impl AusAdapter {
13 pub fn new(sample_rate: u32) -> Self {
15 Self { sample_rate }
16 }
17
18 pub fn read_audio_file<P: AsRef<Path>>(&self, path: P) -> Result<AudioFile> {
20 let path_ref = path.as_ref();
21 let path_str = path_ref
22 .to_str()
23 .ok_or_else(|| SubXError::audio_processing("無法轉換路徑為 UTF-8 字串"))?;
24 aus::read(path_str)
25 .map_err(|e| SubXError::audio_processing(format!("aus 讀取音訊檔案失敗: {:?}", e)))
26 }
27
28 pub fn to_subx_audio_data(
30 &self,
31 _audio_file: &AudioFile,
32 ) -> Result<crate::services::audio::AudioData> {
33 todo!("將在後續階段實作 aus to AudioData 轉換")
35 }
36}