Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stream audio with POST request #183

Open
iamklim opened this issue Nov 6, 2023 · 4 comments
Open

Stream audio with POST request #183

iamklim opened this issue Nov 6, 2023 · 4 comments

Comments

@iamklim
Copy link

iamklim commented Nov 6, 2023

Hello! Can I use SwiftAudioPlayer with ElevenLabs Text to Speech Stream API request?

I understand how to stream audio with GET request acc. to docs:

let url = URL(string: "https://randomwebsite.com/audio.mp3")!
SAPlayer.shared.startRemoteAudio(withRemoteUrl: url)
SAPlayer.shared.play()

But what if I need also to attach payload to POST request like

var request = URLRequest(url: url)
request.httpMethod = "POST"
let payload: [String: Any] = [
            "text": "Hello",
            "model_id": "eleven_multilingual_v2",
            "voice_settings": [
              "stability": 0.5,
              "similarity_boost": 0.75,
            ]
        ]
let jsonData = try? JSONSerialization.data(withJSONObject: payload, options: .fragmentsAllowed)
request.httpBody = jsonData

Response returns audio as an audio stream.
Is it possible somehow?

@mikeg0184
Copy link

@iamklim did you find a way to get streaming audio from elevenlabs to work in Swift? I'm trying to do the seame thing.

@snboyle16
Copy link

@iamklim @mgerstenblatt I am trying to figure out the same thing! Any tips?

@shinedlc
Copy link

shinedlc commented Jun 7, 2024

me too

@mikeg0184
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants