| @@ -120,8 +120,46 @@ | ||
| 120 | 120 | ) ); |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | /** |
| 124 | + * Speech-to-text model per platform, for audio and video attachments. | |
| 125 | + * | |
| 126 | + * Kept apart from the chat catalogue above because it is not a user choice: | |
| 127 | + * the Settings model picker selects the model that *writes the doc*, while | |
| 128 | + * transcription is a fixed preprocessing step. A platform absent from this | |
| 129 | + * map cannot transcribe, which is what Core\WriteWithAI::platform_supports() | |
| 130 | + * reads — so adding a key here is all it takes to light up a new provider. | |
| 131 | + * | |
| 132 | + * @since 4.9.4 | |
| 133 | + * | |
| 134 | + * @return array<string,string> | |
| 135 | + */ | |
| 136 | + public static function transcription_models() { | |
| 137 | + return apply_filters( 'betterdocs_ai_transcription_models', array( | |
| 138 | + // Cheaper and faster than whisper-1 at comparable accuracy, and it | |
| 139 | + // accepts the same container list — including video, whose audio | |
| 140 | + // track the endpoint extracts server-side. | |
| 141 | + 'openai' => 'gpt-4o-mini-transcribe', | |
| 142 | + // Gemini has no speech endpoint; the media rides inline in an | |
| 143 | + // ordinary generateContent call, so this is a normal chat model. | |
| 144 | + 'gemini' => 'gemini-flash-latest', | |
| 145 | + ) ); | |
| 146 | + } | |
| 147 | + | |
| 148 | + /** | |
| 149 | + * The transcription model for a platform, or '' when it cannot transcribe. | |
| 150 | + * | |
| 151 | + * @since 4.9.4 | |
| 152 | + * | |
| 153 | + * @param string $platform | |
| 154 | + * @return string | |
| 155 | + */ | |
| 156 | + public static function transcription_model( $platform ) { | |
| 157 | + $models = self::transcription_models(); | |
| 158 | + return isset( $models[ $platform ] ) ? (string) $models[ $platform ] : ''; | |
| 159 | + } | |
| 160 | + | |
| 161 | + /** | |
| 124 | 162 | * Models for one platform (model_id => label). Empty array if unknown. |
| 125 | 163 | * |
| 126 | 164 | * @param string $platform |
| 127 | 165 | * @return array<string,string> |