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
61 changes: 39 additions & 22 deletions examples/models/parakeet/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -108,32 +108,49 @@ if(EXECUTORCH_BUILD_VULKAN)
executorch_target_link_options_shared_lib(vulkan_backend)
endif()

add_executable(parakeet_runner main.cpp timestamp_utils.cpp tokenizer_utils.cpp)
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
target_link_options_gc_sections(parakeet_runner)
if(NOT APPLE AND NOT MSVC)
target_link_options(parakeet_runner PRIVATE "LINKER:-s")
endif()
endif()
set(parakeet_shared_sources parakeet_transcriber.cpp timestamp_utils.cpp
tokenizer_utils.cpp
)

# Copy MLX metallib for runtime if MLX delegate is enabled
if(TARGET mlxdelegate)
executorch_target_copy_mlx_metallib(parakeet_runner)
endif()
set(parakeet_common_include_directories
${_common_include_directories} ${EXECUTORCH_ROOT}/third-party/json/include
)

target_include_directories(
parakeet_runner PUBLIC ${_common_include_directories}
add_executable(parakeet_runner main.cpp ${parakeet_shared_sources})
add_executable(
parakeet_helper parakeet_helper.cpp parakeet_helper_protocol.cpp
${parakeet_shared_sources}
)
target_link_libraries(parakeet_runner PUBLIC ${link_libraries})
target_compile_options(parakeet_runner PUBLIC ${_common_compile_options})

foreach(parakeet_target parakeet_runner parakeet_helper)
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
target_link_options_gc_sections(${parakeet_target})
if(NOT APPLE AND NOT MSVC)
target_link_options(${parakeet_target} PRIVATE "LINKER:-s")
endif()
endif()

if(TARGET mlxdelegate)
executorch_target_copy_mlx_metallib(${parakeet_target})
endif()

target_include_directories(
${parakeet_target} PUBLIC ${parakeet_common_include_directories}
)
target_link_libraries(${parakeet_target} PUBLIC ${link_libraries})
target_compile_options(${parakeet_target} PUBLIC ${_common_compile_options})
endforeach()

# On Windows, copy required DLLs to the executable directory
if(MSVC AND EXECUTORCH_BUILD_CUDA)
add_custom_command(
TARGET parakeet_runner
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:aoti_cuda_shims>
$<TARGET_FILE_DIR:parakeet_runner>
COMMENT "Copying aoti_cuda_shims.dll to parakeet_runner directory"
)
foreach(parakeet_target parakeet_runner parakeet_helper)
add_custom_command(
TARGET ${parakeet_target}
POST_BUILD
COMMAND
${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:aoti_cuda_shims>
$<TARGET_FILE_DIR:${parakeet_target}>
COMMENT "Copying aoti_cuda_shims.dll to ${parakeet_target} directory"
)
endforeach()
endif()
12 changes: 6 additions & 6 deletions examples/models/parakeet/CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,42 +89,42 @@
"displayName": "Build Parakeet runner (CPU)",
"configurePreset": "parakeet-cpu",
"configuration": "Release",
"targets": ["parakeet_runner"]
"targets": ["parakeet_runner", "parakeet_helper"]
},
{
"name": "parakeet-cuda",
"displayName": "Build Parakeet runner (CUDA)",
"configurePreset": "parakeet-cuda",
"configuration": "Release",
"targets": ["parakeet_runner"]
"targets": ["parakeet_runner", "parakeet_helper"]
},
{
"name": "parakeet-cuda-debug",
"displayName": "Build Parakeet runner (CUDA, Debug)",
"configurePreset": "parakeet-cuda-debug",
"configuration": "Debug",
"targets": ["parakeet_runner"]
"targets": ["parakeet_runner", "parakeet_helper"]
},
{
"name": "parakeet-metal",
"displayName": "Build Parakeet runner (Metal)",
"configurePreset": "parakeet-metal",
"configuration": "Release",
"targets": ["parakeet_runner"]
"targets": ["parakeet_runner", "parakeet_helper"]
},
{
"name": "parakeet-mlx",
"displayName": "Build Parakeet runner (MLX)",
"configurePreset": "parakeet-mlx",
"configuration": "Release",
"targets": ["parakeet_runner"]
"targets": ["parakeet_runner", "parakeet_helper"]
},
{
"name": "parakeet-vulkan",
"displayName": "Build Parakeet runner (Vulkan)",
"configurePreset": "parakeet-vulkan",
"configuration": "Release",
"targets": ["parakeet_runner"]
"targets": ["parakeet_runner", "parakeet_helper"]
}
],
"workflowPresets": [
Expand Down
25 changes: 25 additions & 0 deletions examples/models/parakeet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,11 @@ make parakeet-cuda
make parakeet-mlx
```

Each Parakeet build now produces both:

- `parakeet_runner` for one-shot CLI transcription from an audio file
- `parakeet_helper` for long-lived host integrations that keep the model warm and stream PCM requests over stdin/stdout

On Windows (PowerShell), use CMake workflow presets directly:

```powershell
Expand Down Expand Up @@ -286,6 +291,26 @@ If your generator is single-config, the runner may be at `.\cmake-out\examples\m
| `--data_path` | Path to data file (.ptd) for delegate data (required for CUDA/CUDA-Windows) |
| `--timestamps` | Timestamp output mode: `none\|token\|word\|segment\|all` (default: `segment`) |

### Persistent Helper

The helper binary uses the same Parakeet transcription stack as `parakeet_runner`,
but keeps the model loaded across multiple requests so host apps can avoid repeated
startup and model load overhead.

Example:

```bash
# Metal
DYLD_LIBRARY_PATH=/usr/lib ./cmake-out/examples/models/parakeet/parakeet_helper \
--model_path examples/models/parakeet/parakeet_metal/model.pte \
--tokenizer_path examples/models/parakeet/parakeet_metal/tokenizer.model
```

The helper accepts framed requests over stdin, validates 16 kHz mono float32 PCM
payloads, and returns status/result messages over stdout. It is intended for app
integrations such as the macOS `ExecuWhisper` frontend in the separate
`executorch-examples` repository.

### Mobile App

Check out a [demo Android app](https://github.com/meta-pytorch/executorch-examples/tree/main/parakeet/android/ParakeetApp) for Parakeet in the separate `executorch-examples` repository.
Expand Down
Loading
Loading