  **/
 
 import Foundation
-import Starscream
+
 import ObjectMapper
 
 /**
     The IBM® Speech to Text service provides an Application Programming Interface (API) that
     enables you to add speech transcription capabilities to your applications.
 */
-public class SpeechToText: Service {
-    
-    private let tokenURL = "https://stream.watsonplatform.net/authorization/api/v1/token"
-    private let serviceURL = "/speech-to-text/api"
-    private let serviceURLFull = "https://stream.watsonplatform.net/speech-to-text/api"
-    private let url = "wss://stream.watsonplatform.net/speech-to-text/api/v1/recognize"
-    
-    public enum SpeechToTextAudioFormat: String {
-        case OGG        = "audio/ogg;codecs=opus"
-        case FLAC       = "audio/flac"
-        case PCM        = "audio/l16"
-        case WAV        = "audio/wav"
-    }
+public class SpeechToText {
+    
+    
     
     private let WATSON_AUDIO_SAMPLE_RATE = 16000
     private let WATSON_AUDIO_FRAME_SIZE = 160
     
     
     // NSOperationQueues
-    var audioUploadQueue: NSOperationQueue!
     var transcriptionQueue: NSOperationQueue!
     
     
     public var delegate : SpeechToTextDelegate?
     
-    var socket: WebSocket?
+    
     
     private let opus: OpusHelper = OpusHelper()
     private let ogg: OggHelper = OggHelper()
     
-    var format: SpeechToTextAudioFormat = .FLAC
+    private let watsonSocket = WatsonSocket()
+   
     
     var audioData: NSData?
     

//            AudioQueueBufferRef(),
//            AudioQueueBufferRef()]
        
        connectWebsocket()
        
        let format = AudioStreamBasicDescription(
            mSampleRate: 16000,

            return 
        }
        
        
        let chunkSize: Int = watsonFrameSize * 2
        var offset : Int = 0
        
        var ptr = UnsafeMutablePointer<UInt8>(buffer.mAudioData)
        
        let newData = NSData(bytesNoCopy: ptr, length: Int(buffer.mAudioDataByteSize), freeWhenDone: false)
        
        Log.sharedLogger.info("Added the audio to the queue")
        //let o1 = AudioUploadOperation(data: newData, socket: data.socket!)
        //data.audioUploadQueue.addOperation(o1)
        
        
        // Tell the buffer it's free to accept more data
