 }
 
 enum VoicevoxWrapperError: Error {
+    // XXX: More cases.
     case `internal`
 }
 

import Foundation
import Alamofire

// TODO: to static
protocol VoicevoxWrapperType {
    func requestSpeakers(completion: @escaping SpeakersRequestCompletion)
    func requestAudio(text: String, speedScale: Float, volumeScale: Float, speaker: Int, completion: @escaping AudioRequestCompletion)

}

private extension VoicevoxWrapper {
    func handleSpeakersResponse(_ response: AFDataResponse<Data>, completion: @escaping SpeakersRequestCompletion) {
        switch response.result {
        case .success(let data):
            guard let decoded = try? JSONDecoder().decode([VoicevoxSpeakerResponse].self, from: data) else {
                completion(Result.failure(.internal))
                return
            }
            completion(Result.success(decoded.toVoicevoxSpeakers()))
        case .failure(let error):
            log.error(error)
            completion(Result.failure(.internal))
        }
    }

    func requestAudioQuery(config: AudioConfiguration, completion: @escaping AudioRequestCompletion) {
        log.debug("\(config.text), \(config.speedScale), \(config.speaker)")
        let urlString = voicevoxUrl + "/audio_query?text=\(config.text.escapsed)&speaker=\(config.speaker)"
