From 28dbe5a2f66bcb1994ce2a17225118ee1ea5ab2a Mon Sep 17 00:00:00 2001 From: Beingpax Date: Wed, 9 Jul 2025 10:20:02 +0545 Subject: [PATCH] Fix: Cloud transcription errors --- VoiceInk/Services/AIService.swift | 21 ++++++++----------- .../DeepgramTranscriptionService.swift | 4 +--- .../ElevenLabsTranscriptionService.swift | 1 + 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/VoiceInk/Services/AIService.swift b/VoiceInk/Services/AIService.swift index 191044e..f06cf2e 100644 --- a/VoiceInk/Services/AIService.swift +++ b/VoiceInk/Services/AIService.swift @@ -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() } diff --git a/VoiceInk/Services/CloudTranscription/DeepgramTranscriptionService.swift b/VoiceInk/Services/CloudTranscription/DeepgramTranscriptionService.swift index d2b6b91..905aa9f 100644 --- a/VoiceInk/Services/CloudTranscription/DeepgramTranscriptionService.swift +++ b/VoiceInk/Services/CloudTranscription/DeepgramTranscriptionService.swift @@ -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 { diff --git a/VoiceInk/Services/CloudTranscription/ElevenLabsTranscriptionService.swift b/VoiceInk/Services/CloudTranscription/ElevenLabsTranscriptionService.swift index a65ec0a..9a6b4dc 100644 --- a/VoiceInk/Services/CloudTranscription/ElevenLabsTranscriptionService.swift +++ b/VoiceInk/Services/CloudTranscription/ElevenLabsTranscriptionService.swift @@ -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)