Fix: Cloud transcription errors

This commit is contained in:
Beingpax 2025-07-09 10:20:02 +05:45
parent 0ad5b20068
commit 28dbe5a2f6
3 changed files with 11 additions and 15 deletions

View File

@ -410,23 +410,20 @@ class AIService: ObservableObject {
private func verifyElevenLabsAPIKey(_ key: String, completion: @escaping (Bool) -> Void) {
let url = URL(string: "https://api.elevenlabs.io/v1/user")!
var request = URLRequest(url: url)
request.httpMethod = "GET"
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
request.addValue(key, forHTTPHeaderField: "xi-api-key")
URLSession.shared.dataTask(with: request) { _, response, error in
if let error = error {
self.logger.error("ElevenLabs API key verification failed: \(error.localizedDescription)")
completion(false)
return
}
if let httpResponse = response as? HTTPURLResponse {
completion(httpResponse.statusCode == 200)
} else {
completion(false)
URLSession.shared.dataTask(with: request) { data, response, _ in
let isValid = (response as? HTTPURLResponse)?.statusCode == 200
if let data = data, let body = String(data: data, encoding: .utf8) {
self.logger.info("ElevenLabs verification response: \(body)")
}
completion(isValid)
}.resume()
}

View File

@ -59,10 +59,8 @@ class DeepgramTranscriptionService {
queryItems.append(contentsOf: [
URLQueryItem(name: "smart_format", value: "true"),
URLQueryItem(name: "dictation", value: "true"),
URLQueryItem(name: "punctuate", value: "true"),
URLQueryItem(name: "paragraphs", value: "true"),
URLQueryItem(name: "filler_words", value: "false")
URLQueryItem(name: "paragraphs", value: "true")
])
if selectedLanguage != "auto" && !selectedLanguage.isEmpty {

View File

@ -9,6 +9,7 @@ class ElevenLabsTranscriptionService {
var request = URLRequest(url: config.url)
request.httpMethod = "POST"
request.setValue("multipart/form-data; boundary=\(boundary)", forHTTPHeaderField: "Content-Type")
request.setValue("application/json", forHTTPHeaderField: "Accept")
request.setValue(config.apiKey, forHTTPHeaderField: "xi-api-key")
let body = try createElevenLabsRequestBody(audioURL: audioURL, modelName: config.modelName, boundary: boundary)