| 1 | package Langertha::Engine::TranscriptionBase; | ||
| 2 | # ABSTRACT: Base class for OpenAI-compatible transcription-only engines | ||
| 3 | 102 | our $VERSION = '0.503'; | |
| 4 | 102 | ▶ | use Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 102 | ▶ | use Carp qw( croak ); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | 102 | ▶ | use Module::Runtime qw( use_module ); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | |||
| 8 | 102 | extends 'Langertha::Engine::Remote'; | |
| 9 | |||
| 10 | 102 | with map { 'Langertha::Role::'.$_ } qw( | |
| 11 | OpenAICompatible | ||
| 12 | OpenAPI | ||
| 13 | Models | ||
| 14 | Transcription | ||
| 15 | Capabilities | ||
| 16 | ); | ||
| 17 | |||
| 18 | 7 | ▶ | sub _build_openapi_operations { |
|
Subroutine
_build_openapi_operations: called CC=1 SCAR=0.0
| |||
| 19 | 7 | return use_module('Langertha::Spec::OpenAI')->data; | |
| 20 | } | ||
| 21 | |||
| 22 | 9 | ▶ | sub _build_supported_operations {[qw( |
|
Subroutine
_build_supported_operations: called CC=1 SCAR=0.0
| |||
| 23 | createTranscription | ||
| 24 | )]} | ||
| 25 | |||
| 26 | |||
| 27 | 0 | ▶ | sub default_model { croak "".(ref $_[0])." requires transcription_model to be set" } |
|
Subroutine
default_model: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 28 | |||
| 29 | 102 | __PACKAGE__->meta->make_immutable; | |
| 30 | |||
| 31 | |||
| 32 | 102 | 1; | |
| 33 | |||
| 34 | __END__ | ||
| 35 | |||
| 36 | =pod | ||
| 37 | |||
| 38 | =encoding UTF-8 | ||
| 39 | |||
| 40 | =head1 NAME | ||
| 41 | |||
| 42 | Langertha::Engine::TranscriptionBase - Base class for OpenAI-compatible transcription-only engines | ||
| 43 | |||
| 44 | =head1 VERSION | ||
| 45 | |||
| 46 | version 0.503 | ||
| 47 | |||
| 48 | =head1 SYNOPSIS | ||
| 49 | |||
| 50 | package My::TranscriptionEngine; | ||
| 51 | use Moose; | ||
| 52 | extends 'Langertha::Engine::TranscriptionBase'; | ||
| 53 | |||
| 54 | has '+url' => ( default => 'https://api.example.com/v1' ); | ||
| 55 | |||
| 56 | sub _build_api_key { $ENV{MY_API_KEY} || die "MY_API_KEY required" } | ||
| 57 | sub default_transcription_model { 'whisper-large-v3' } # optional | ||
| 58 | |||
| 59 | __PACKAGE__->meta->make_immutable; | ||
| 60 | |||
| 61 | =head1 DESCRIPTION | ||
| 62 | |||
| 63 | Slim base class for engines that only do audio transcription via the | ||
| 64 | OpenAI-shape C</audio/transcriptions> endpoint. Unlike L<Langertha::Engine::OpenAIBase>, this does not | ||
| 65 | compose L<Langertha::Role::Chat> / L<Langertha::Role::Tools> / | ||
| 66 | L<Langertha::Role::Embedding> / L<Langertha::Role::ImageGeneration> | ||
| 67 | — callers get a focused object with C<simple_transcription> and | ||
| 68 | nothing else. | ||
| 69 | |||
| 70 | L<Langertha::Engine::Whisper> is the canonical concrete subclass for | ||
| 71 | self-hosted Whisper servers; L<Langertha::Engine::OpenAI> exposes a | ||
| 72 | C<whisper> attribute that returns a TranscriptionBase configured for | ||
| 73 | the OpenAI cloud (sharing the parent's C<api_key> and C<url>) so | ||
| 74 | chat-side code can grab a transcription handle without re-stating the | ||
| 75 | credentials. | ||
| 76 | |||
| 77 | C<transcription_model> defaults to C<whisper-1>, the model name | ||
| 78 | OpenAI-compatible transcription servers widely accept. OpenAI's newer | ||
| 79 | C<gpt-transcribe> is only the default on L<Langertha::Engine::OpenAI> and its | ||
| 80 | C<whisper> handle, since other servers do not know it. A subclass for a server | ||
| 81 | that wants another default overrides C<default_transcription_model> | ||
| 82 | (L<Langertha::Engine::Whisper> returns C<''> and lets the server choose); a | ||
| 83 | caller can always pass C<transcription_model>. | ||
| 84 | |||
| 85 | =head1 SEE ALSO | ||
| 86 | |||
| 87 | =over | ||
| 88 | |||
| 89 | =item * L<Langertha::Engine::Whisper> - Self-hosted Whisper-compatible server | ||
| 90 | |||
| 91 | =item * L<Langertha::Engine::OpenAI> - Provides a C<whisper> handle reusing its credentials | ||
| 92 | |||
| 93 | =item * L<Langertha::Role::Transcription> - The role this base composes | ||
| 94 | |||
| 95 | =back | ||
| 96 | |||
| 97 | =head1 SUPPORT | ||
| 98 | |||
| 99 | =head2 Issues | ||
| 100 | |||
| 101 | Please report bugs and feature requests on GitHub at | ||
| 102 | L<https://github.com/Getty/langertha/issues>. | ||
| 103 | |||
| 104 | =head2 IRC | ||
| 105 | |||
| 106 | Join C<#langertha> on C<irc.perl.org> or message Getty directly. | ||
| 107 | |||
| 108 | =head1 CONTRIBUTING | ||
| 109 | |||
| 110 | Contributions are welcome! Please fork the repository and submit a pull request. | ||
| 111 | |||
| 112 | =head1 AUTHOR | ||
| 113 | |||
| 114 | Torsten Raudssus <getty@cpan.org> | ||
| 115 | |||
| 116 | =head1 COPYRIGHT AND LICENSE | ||
| 117 | |||
| 118 | This software is copyright (c) 2026 by Torsten Raudssus L<https://raudssus.de/>. | ||
| 119 | |||
| 120 | This is free software; you can redistribute it and/or modify it under | ||
| 121 | the same terms as the Perl 5 programming language system itself. | ||
| 122 | |||
| 123 | =cut | ||