mirror of
https://github.com/taigrr/elevenlabs.git
synced 2026-04-01 18:58:52 -07:00
fix nil error pointed out by @Davincible , closes #1
This commit is contained in:
@@ -30,14 +30,13 @@ func (c Client) TTSWriter(ctx context.Context, w io.Writer, text, voiceID string
|
||||
req.Header.Set("User-Agent", "github.com/taigrr/elevenlabs")
|
||||
req.Header.Set("accept", "audio/mpeg")
|
||||
res, err := client.Do(req)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
switch res.StatusCode {
|
||||
case 401:
|
||||
return ErrUnauthorized
|
||||
case 200:
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer res.Body.Close()
|
||||
io.Copy(w, res.Body)
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user