Skip to content

Commit

Permalink
remove files after and send file readings
Browse files Browse the repository at this point in the history
  • Loading branch information
akorchyn committed Feb 4, 2024
1 parent 819a9d8 commit d634310
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/openai/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,10 @@ impl OpenAIClient {
audio_file: &str,
) -> anyhow::Result<audio::AudioTranscriptionResponse> {
let client: Client = Client::new(self.api_key.clone());
let file = std::fs::read_to_string(audio_file)?;

let req =
AudioTranscriptionRequest::new(audio_file.to_string(), audio::WHISPER_1.to_string())
.temperature(0.2);
AudioTranscriptionRequest::new(file, audio::WHISPER_1.to_string()).temperature(0.2);

let result = client.audio_transcription(req)?;

Expand Down
8 changes: 7 additions & 1 deletion src/openai/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,11 +265,17 @@ impl Processor {
}
destination
} else {
save_path
save_path.clone()
};
log::info!("Converting audio to text");
let text = self.openai.audio_to_text(&file)?;

// Remove the file
tokio::fs::remove_file(&file).await?;
if is_video {
tokio::fs::remove_file(&save_path).await?;
}

log::info!("Summarizing transcribed text");
let result = self
.openai
Expand Down

0 comments on commit d634310

Please sign in to comment.