CreateAudioOutputFile creates a binary file for audio data
(audioData []byte, fileName string)
| 43 | |
| 44 | // CreateAudioOutputFile creates a binary file for audio data |
| 45 | func CreateAudioOutputFile(audioData []byte, fileName string) (err error) { |
| 46 | // If no extension is provided, default to .wav |
| 47 | if filepath.Ext(fileName) == "" { |
| 48 | fileName += ".wav" |
| 49 | } |
| 50 | |
| 51 | // File existence check is now done in the CLI layer before TTS generation |
| 52 | var file *os.File |
| 53 | if file, err = os.Create(fileName); err != nil { |
| 54 | err = fmt.Errorf(i18n.T("error_creating_audio_file"), err) |
| 55 | return |
| 56 | } |
| 57 | defer file.Close() |
| 58 | |
| 59 | if _, err = file.Write(audioData); err != nil { |
| 60 | err = fmt.Errorf(i18n.T("error_writing_audio_data"), err) |
| 61 | } |
| 62 | // No redundant output message here - the CLI layer handles success messaging |
| 63 | return |
| 64 | } |
| 65 | |
| 66 | // IsAudioFormat checks if the filename suggests an audio format |
| 67 | func IsAudioFormat(fileName string) bool { |
no test coverage detected