#Audio plays in XCode but not TestFlight

1 messages · Page 1 of 1 (latest)

tulip cargo
#

Issue:
I have a swift app, where the ElevenLabs generated audio will play in XCode but not on iPhones through TestFlight. I am able to play other types of audio, just not the ElevenLabs audio I'm generating and then playing

Points of failure I've thought about:

  • App logic- not this because I'm doing the same behavior each time to generate the tts audio so if everything logically speaking is the same in xcode I think it should work in TestFlight
  • New logical failure when running on iPhone- At each point where the audio retrieval can fail I've added print statements so I can see if any errors occurred but none did
  • iPhone Issue- my iPhone is up to date, have also tried with another one, (Silence, DND, Volume- off, off, high respectively)

Could anyone help point me in the right direction?

#

func textToSpeech(botSpeech: String) {
print("textToSpeech")

    // Create the request
    let url = URL(string: "\(apiUrl)/v1/text-to-speech/\(GlobalVars.shared.voiceId)")!
    var request = URLRequest(url: url)
    request.httpMethod = "POST"
    request.addValue(apiKey, forHTTPHeaderField: "xi-api-key")
    request.addValue("application/json", forHTTPHeaderField: "Content-Type")
    
    // Create the request body
    let requestBody: [String: Any] = [
        "text": botSpeech,
        "voice_settings": [
            "stability": 0,
            "similarity_boost": 0
        ]
    ]
    do {
        let jsonData = try JSONSerialization.data(withJSONObject: requestBody)
        request.httpBody = jsonData
    } catch {
        print("**** ERROR: Failed to serialize JSON; \(error.localizedDescription) - textToSpeech")

        return
    }
    
    URLSession.shared.dataTask(with: request) { data, response, error in
        if let error = error {
            print("**** ERROR: \(error.localizedDescription) - textToSpeech")
            return
        }
        
        guard let data = data else {
            print("**** ERROR: No data received - textToSpeech")

            return
        }
        
        // Parse the audio response
        do {
            let pAudioPlayer = try AVAudioPlayer(data: data)
            print("    Audio player initialized")
            gAudioPlayer = pAudioPlayer
            
            // Set the delegate to the instance of SpeechRec
            gAudioPlayer?.delegate = self
            
            gAudioPlayer?.play()
        } catch let audioError {
            print("**** Error: Failed to create audio player; \(audioError.localizedDescription) - textToSpeech")

        }
    }.resume()
}// end of textToSpeech
tulip cargo
#

@toxic torrent Hi, do you have any ideas or know of any people that could help? I'm currently testing if the api will work when I plug the phone into the mac directly using a cable and secondly creating an extremely simple app that plays an elevenlabs voice through the api