Langertha/Role/Transcription.pm

filter: Statementstmt 60.0% 12 / 20 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 60.0% 3 / 5 Podpod 100% 2 / 2 totaltotal 54.8% 17 / 31 CC 3 SCAR 17.7
CC
3
Cov
50%
_build_transcription_model
12.0
simple_transcription
2.0
BEGIN
1.0
CRAP 5.9
« Langertha/Role/Tools.pm ↑ Summary Langertha/Metrics.pm »
1 package Langertha::Role::Transcription;
2 # ABSTRACT: Role for APIs with transcription functionality
3 26 our $VERSION = '0.502';
4 26 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 26 ▶use Carp qw( croak );
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 26 requires qw(
8 transcription_request
9 transcription_response
10 );
11  
12 26 has transcription_model => (
13 is => 'ro',
14 isa => 'Str',
15 lazy_build => 1,
16 );
17 sub _build_transcription_model {
18 0 ▶ my ( $self ) = @_;
Subroutine _build_transcription_model: not called CC=3 SCAR=24.8
19 0 ▶ croak "".(ref $self)." can't handle models!" unless $self->does('Langertha::Role::Models');
Branch: 1 branch
BranchTrueFalseTotal
unless $self->does("Langertha::Role::Models") 0 0 0
20 0 ▶ return $self->default_transcription_model if $self->can('default_transcription_model');
Branch: 1 branch
BranchTrueFalseTotal
if $self->can("default_transcription_model") 0 0 0
21 0 return $self->model;
22 }
23  
24  
25 sub transcription {
26 1 ▶ my ( $self, $file_or_content, %extra ) = @_;
Subroutine transcription: called CC=1 SCAR=0.0
Pod documented
27 1 return $self->transcription_request($file_or_content, %extra);
28 }
29  
30  
31 sub simple_transcription {
32 0 ▶ my ( $self, $file_or_content, %extra ) = @_;
Subroutine simple_transcription: not called CC=1 SCAR=6.9
Pod documented
33 0 my $request = $self->transcription($file_or_content, %extra);
34 0 my $response = $self->user_agent->request($request);
35 0 return $request->response_call->($response);
36 }
37  
38  
39  
40 26 1;
41  
42 __END__
43  
44 =pod
45  
46 =encoding UTF-8
47  
48 =head1 NAME
49  
50 Langertha::Role::Transcription - Role for APIs with transcription functionality
51  
52 =head1 VERSION
53  
54 version 0.502
55  
56 =head2 transcription_model
57  
58 The model name to use for transcription requests. Lazily defaults to
59 C<default_transcription_model> if the engine provides it, otherwise falls back
60 to the general C<model> attribute from L<Langertha::Role::Models>.
61  
62 =head2 transcription
63  
64 my $request = $engine->transcription($file_or_content, %extra);
65  
66 Builds and returns a transcription HTTP request object for the given audio
67 file path or content. Use L</simple_transcription> to execute the request
68 and get the transcript directly.
69  
70 =head2 simple_transcription
71  
72 my $text = $engine->simple_transcription($file_or_content, %extra);
73 my $text = $engine->simple_transcription('/path/to/audio.mp3');
74 my $text = $engine->simple_transcription($audio_bytes, language => 'en');
75  
76 Sends a transcription request for the audio file or content and returns the
77 transcript text. Blocks until the request completes. Additional options such as
78 C<language> can be passed as C<%extra> key/value pairs.
79  
80 =head1 SEE ALSO
81  
82 =over
83  
84 =item * L<Langertha::Role::HTTP> - HTTP transport layer
85  
86 =item * L<Langertha::Role::Models> - Model selection (provides C<transcription_model>)
87  
88 =item * L<Langertha::Engine::Whisper> - Whisper-compatible transcription server
89  
90 =item * L<Langertha::Engine::Groq> - Groq's hosted Whisper transcription
91  
92 =back
93  
94 =head1 SUPPORT
95  
96 =head2 Issues
97  
98 Please report bugs and feature requests on GitHub at
99 L<https://github.com/Getty/langertha/issues>.
100  
101 =head2 IRC
102  
103 Join C<#langertha> on C<irc.perl.org> or message Getty directly.
104  
105 =head1 CONTRIBUTING
106  
107 Contributions are welcome! Please fork the repository and submit a pull request.
108  
109 =head1 AUTHOR
110  
111 Torsten Raudssus <getty@cpan.org>
112  
113 =head1 COPYRIGHT AND LICENSE
114  
115 This software is copyright (c) 2026 by Torsten Raudssus L<https://raudssus.de/>.
116  
117 This is free software; you can redistribute it and/or modify it under
118 the same terms as the Perl 5 programming language system itself.
119  
120 =cut
« Langertha/Role/Tools.pm ↑ Summary Langertha/Metrics.pm »