Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

clippy

Richie McIlroy245111c11ceb
diff --git a/apps/desktop/src-tauri/src/captions.rs b/apps/desktop/src-tauri/src/captions.rs
index f07dfdcb4..a0224c4ea 100644
--- a/apps/desktop/src-tauri/src/captions.rs
+++ b/apps/desktop/src-tauri/src/captions.rs
@@ -396,17 +396,17 @@ async fn extract_audio_from_video(video_path: &str, output_path: &PathBuf) -> Re
{
for (stream_idx, packet) in input.packets() {
- if stream_idx.index() == input_stream_index {
- if let Some(data) = packet.data() {
- let mut cloned_packet = ffmpeg::Packet::copy(data);
- if let Some(pts) = packet.pts() {
- cloned_packet.set_pts(Some(pts));
- }
- if let Some(dts) = packet.dts() {
- cloned_packet.set_dts(Some(dts));
- }
- packet_queue.push(cloned_packet);
+ if stream_idx.index() == input_stream_index
+ && let Some(data) = packet.data()
+ {
+ let mut cloned_packet = ffmpeg::Packet::copy(data);
+ if let Some(pts) = packet.pts() {
+ cloned_packet.set_pts(Some(pts));
+ }
+ if let Some(dts) = packet.dts() {
+ cloned_packet.set_dts(Some(dts));
}
+ packet_queue.push(cloned_packet);
}
}
}
@@ -673,20 +673,20 @@ fn process_with_whisper(
);
if token_text.starts_with(' ') || token_text.starts_with('\n') {
- if !current_word.is_empty() {
- if let Some(ws) = word_start {
- log::info!(
- " -> Completing word: '{}' ({:.2}s - {:.2}s)",
- current_word.trim(),
- ws,
- word_end
- );
- words.push(CaptionWord {
- text: current_word.trim().to_string(),
- start: ws,
- end: word_end,
- });
- }
+ if !current_word.is_empty()
+ && let Some(ws) = word_start
+ {
+ log::info!(
+ " -> Completing word: '{}' ({:.2}s - {:.2}s)",
+ current_word.trim(),
+ ws,
+ word_end
+ );
+ words.push(CaptionWord {
+ text: current_word.trim().to_string(),
+ start: ws,
+ end: word_end,
+ });
}
current_word = token_text.trim().to_string();
word_start = Some(token_start);
@@ -714,20 +714,20 @@ fn process_with_whisper(
}
}
- if !current_word.trim().is_empty() {
- if let Some(ws) = word_start {
- log::info!(
- " -> Final word: '{}' ({:.2}s - {:.2}s)",
- current_word.trim(),
- ws,
- word_end
- );
- words.push(CaptionWord {
- text: current_word.trim().to_string(),
- start: ws,
- end: word_end,
- });
- }
+ if !current_word.trim().is_empty()
+ && let Some(ws) = word_start
+ {
+ log::info!(
+ " -> Final word: '{}' ({:.2}s - {:.2}s)",
+ current_word.trim(),
+ ws,
+ word_end
+ );
+ words.push(CaptionWord {
+ text: current_word.trim().to_string(),
+ start: ws,
+ end: word_end,
+ });
}
log::info!(" Segment {} produced {} words", i, words.len());
@@ -808,15 +808,15 @@ fn find_python() -> Option<String> {
};
for cmd in python_commands {
- if let Ok(output) = Command::new(cmd).arg("--version").output() {
- if output.status.success() {
- let version = String::from_utf8_lossy(&output.stdout);
- if version.contains("Python 3")
- || String::from_utf8_lossy(&output.stderr).contains("Python 3")
- {
- log::info!("Found Python 3 at: {}", cmd);
- return Some(cmd.to_string());
- }
+ if let Ok(output) = Command::new(cmd).arg("--version").output()
+ && output.status.success()
+ {
+ let version = String::from_utf8_lossy(&output.stdout);
+ if version.contains("Python 3")
+ || String::from_utf8_lossy(&output.stderr).contains("Python 3")
+ {
+ log::info!("Found Python 3 at: {}", cmd);
+ return Some(cmd.to_string());
}
}
}
@@ -1572,14 +1572,14 @@ pub async fn transcribe_audio(
Err("Server not available".to_string())
};
- if let Err(ref e) = result {
- if is_server_communication_error(e) {
- log::warn!(
- "Server communication error detected, clearing dead server: {}",
- e
- );
- *server_guard = None;
- }
+ if let Err(ref e) = result
+ && is_server_communication_error(e)
+ {
+ log::warn!(
+ "Server communication error detected, clearing dead server: {}",
+ e
+ );
+ *server_guard = None;
}
result