Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@

<!-- Include audio file in output directory -->
<ItemGroup>
<None Include="Recording.mp3">
<None Include="../../assets/audio/Recording.mp3">
Comment thread
Kazunari001 marked this conversation as resolved.
<Link>Recording.mp3</Link>
<TargetPath>Recording.mp3</TargetPath>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
Expand Down
Binary file not shown.
6 changes: 5 additions & 1 deletion samples/js/audio-transcription-example/app.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// <complete_code>
// <imports>
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { FoundryLocalManager } from 'foundry-local-sdk';
// </imports>

Expand Down Expand Up @@ -40,7 +42,9 @@ const audioClient = model.createAudioClient();
console.log('✓ Audio client created');

// Example audio transcription
const audioFile = process.argv[2] || './Recording.mp3';
const scriptDir = path.dirname(fileURLToPath(import.meta.url));
const defaultAudioFile = path.resolve(scriptDir, '../../assets/audio/Recording.mp3');
const audioFile = process.argv[2] || defaultAudioFile;
console.log(`\nTranscribing ${audioFile}...`);
const transcription = await audioClient.transcribe(audioFile);

Expand Down
Binary file removed samples/python/audio-transcription/Recording.mp3
Binary file not shown.
4 changes: 3 additions & 1 deletion samples/python/audio-transcription/src/app.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# <complete_code>
# <imports>
import sys
from pathlib import Path
from foundry_local_sdk import Configuration, FoundryLocalManager
# </imports>

Expand Down Expand Up @@ -28,7 +29,8 @@
# <transcription>
# Get the audio client and transcribe
audio_client = model.get_audio_client()
audio_file = sys.argv[1] if len(sys.argv) > 1 else "Recording.mp3"
default_audio_file = Path(__file__).resolve().parents[3] / "assets" / "audio" / "Recording.mp3"
audio_file = sys.argv[1] if len(sys.argv) > 1 else str(default_audio_file)
result = audio_client.transcribe(audio_file)
print("Transcription:")
print(result.text)
Expand Down
Binary file not shown.
10 changes: 8 additions & 2 deletions samples/rust/audio-transcription-example/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// <imports>
use std::env;
use std::io::{self, Write};
use std::path::PathBuf;

use foundry_local_sdk::{FoundryLocalConfig, FoundryLocalManager};
use tokio_stream::StreamExt;
Expand All @@ -17,10 +18,15 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("Audio Transcription Example");
println!("===========================\n");

// Accept an optional audio file path as a CLI argument, defaulting to Recording.mp3.
// Accept an optional audio file path as a CLI argument, defaulting to
// ../../assets/audio/Recording.mp3 resolved from CARGO_MANIFEST_DIR.
let audio_path = env::args()
.nth(1)
.unwrap_or_else(|| "Recording.mp3".to_string());
.map(PathBuf::from)
.unwrap_or_else(|| {
PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.join("../../assets/audio/Recording.mp3")
});
Comment thread
Kazunari001 marked this conversation as resolved.

// ── 1. Initialise the manager ────────────────────────────────────────
// <init>
Expand Down