| 7 | import type { VoiceListResponse, SystemVoiceInfo } from '../../types/api'; |
| 8 | |
| 9 | function extractLanguage(voiceId: string): string { |
| 10 | // voice_id format: "Language_VoiceName" or "Language (Dialect)_VoiceName" |
| 11 | // Match up to the last underscore-separated word that starts with uppercase |
| 12 | const match = voiceId.match(/^(.+?)_[A-Z]/); |
| 13 | return match ? match[1] : voiceId; |
| 14 | } |
| 15 | |
| 16 | export function filterByLanguage(voices: SystemVoiceInfo[], language: string): SystemVoiceInfo[] { |
| 17 | const lang = language.toLowerCase(); |