mirror of
https://github.com/taigrr/elevenlabs.git
synced 2026-04-02 03:08:57 -07:00
add voiceList
This commit is contained in:
@@ -104,8 +104,9 @@ func (c Client) DeleteVoice(ctx context.Context, voiceID string) error {
|
|||||||
func (c Client) EditVoiceSettings(ctx context.Context, voiceID string, settings types.SynthesisOptions) error {
|
func (c Client) EditVoiceSettings(ctx context.Context, voiceID string, settings types.SynthesisOptions) error {
|
||||||
url := fmt.Sprintf(c.endpoint+"/v1/voices/%s/settings/edit", voiceID)
|
url := fmt.Sprintf(c.endpoint+"/v1/voices/%s/settings/edit", voiceID)
|
||||||
client := &http.Client{}
|
client := &http.Client{}
|
||||||
// TODO create payload here
|
b, _ := json.Marshal(settings)
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodPost, url, nil)
|
|
||||||
|
req, err := http.NewRequestWithContext(ctx, http.MethodPost, url, bytes.NewReader(b))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -355,3 +356,17 @@ func (c Client) GetVoices(ctx context.Context) ([]types.VoiceResponseModel, erro
|
|||||||
return []types.VoiceResponseModel{}, errors.Join(err, ErrUnspecified)
|
return []types.VoiceResponseModel{}, errors.Join(err, ErrUnspecified)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c Client) GetVoiceIDs(ctx context.Context) ([]string, error) {
|
||||||
|
rms, err := c.GetVoices(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return []string{}, err
|
||||||
|
}
|
||||||
|
list := []string{}
|
||||||
|
|
||||||
|
for _, v := range rms {
|
||||||
|
list = append(list, v.VoiceID)
|
||||||
|
}
|
||||||
|
|
||||||
|
return list, nil
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user