Fix: Cloud transcription errors
This commit is contained in:
parent
0ad5b20068
commit
28dbe5a2f6
@ -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()
|
||||
}
|
||||
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user