assist-feedback.php
10 months ago
assistant.php
10 months ago
base.php
10 months ago
dropped-file.php
11 months ago
edit-image.php
1 year ago
embed.php
10 months ago
feedback.php
10 months ago
function.php
1 year ago
image.php
10 months ago
parameter.php
1 year ago
text.php
10 months ago
transcribe.php
11 months ago
transcribe.php
57 lines
| 1 | <?php |
| 2 | |
| 3 | class Meow_MWAI_Query_Transcribe extends Meow_MWAI_Query_Base { |
| 4 | public string $url = ''; |
| 5 | public ?string $path = null; |
| 6 | public ?string $audioData = null; |
| 7 | public ?string $mimeType = null; |
| 8 | |
| 9 | // Core Content |
| 10 | public ?Meow_MWAI_Query_DroppedFile $attachedFile = null; |
| 11 | |
| 12 | public function __construct( $message = '', $model = 'whisper-1' ) { |
| 13 | parent::__construct( $message ); |
| 14 | $this->set_model( $model ); |
| 15 | $this->feature = 'transcription'; |
| 16 | } |
| 17 | |
| 18 | public function set_url( $url ) { |
| 19 | $this->url = $url; |
| 20 | } |
| 21 | |
| 22 | public function set_path( $path ) { |
| 23 | $this->path = $path; |
| 24 | } |
| 25 | |
| 26 | public function set_audio_data( $data, $mimeType = null ) { |
| 27 | $this->audioData = $data; |
| 28 | $this->mimeType = $mimeType; |
| 29 | } |
| 30 | |
| 31 | // Based on the params of the query, update the attributes |
| 32 | public function inject_params( array $params ): void { |
| 33 | parent::inject_params( $params ); |
| 34 | $params = $this->convert_keys( $params ); |
| 35 | |
| 36 | if ( !empty( $params['url'] ) ) { |
| 37 | $this->set_url( $params['url'] ); |
| 38 | } |
| 39 | if ( !empty( $params['path'] ) ) { |
| 40 | $this->set_path( $params['path'] ); |
| 41 | } |
| 42 | if ( !empty( $params['audioData'] ) || !empty( $params['audio_data'] ) ) { |
| 43 | $audioData = $params['audioData'] ?? $params['audio_data']; |
| 44 | $mimeType = $params['mimeType'] ?? $params['mime_type'] ?? null; |
| 45 | $this->set_audio_data( $audioData, $mimeType ); |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | #region File Handling |
| 50 | |
| 51 | public function set_file( Meow_MWAI_Query_DroppedFile $file ): void { |
| 52 | $this->attachedFile = $file; |
| 53 | } |
| 54 | |
| 55 | #endregion |
| 56 | } |
| 57 |