Closed glennrfisher closed 8 years ago
AVCaptureAudioDataOutput
and AVCaptureAudioDataOutputSampleBufferDelegate
will be very helpful for continuous listening.
I'm copying/pasting this code here for reference, to show an example of a simple application that successfully receives streams of buffer data from the microphone.
(Note that there are no hardware devices available through the simulator, so this code only works successfully when executed on a device.)
//
// ViewController.swift
// MicrophoneDelegate
//
// Created by Glenn Fisher on 1/29/16.
// Copyright © 2016 IBM. All rights reserved.
//
import UIKit
import AVFoundation
class ViewController: UIViewController {
private var session = AVCaptureSession()
override func viewDidLoad() {
super.viewDidLoad()
// add microphone as input
let microphoneDevice = AVCaptureDevice.defaultDeviceWithMediaType(AVMediaTypeAudio)
let microphoneInput = try? AVCaptureDeviceInput(device: microphoneDevice)
if session.canAddInput(microphoneInput) {
session.addInput(microphoneInput) }
// output to sample buffer delegate
let output = AVCaptureAudioDataOutput()
let queue = dispatch_queue_create("sample buffer delegate", DISPATCH_QUEUE_SERIAL)
output.setSampleBufferDelegate(self, queue: queue)
session.addOutput(output)
// start microphone capture session
session.startRunning()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
extension ViewController: AVCaptureAudioDataOutputSampleBufferDelegate {
func captureOutput(
captureOutput: AVCaptureOutput!,
didOutputSampleBuffer sampleBuffer: CMSampleBuffer!,
fromConnection connection: AVCaptureConnection!)
{
print("new sample buffer available for processing")
}
}
Thanks Glenn!
This is great! I'm looking forward to seeing the next version. By the way, do you have any specific date or week v0.2.0 is going to be released?
Hi @dsato80. Glad you're excited for it!
I don't have a specific date, but I will be working on this project full-time for awhile. I'm personally aiming for the end of this week, although it might take me until next week to work out all of the kinks. I'll be sure to post here when it's ready!
I didn't really want to publish any code yet, but had to do so for testing purposes. I'll be open to accepting suggestions and pull requests after merging the speech-to-text
branch into the develop
branch. We may push a release to master
, as well.
I'm looking forward to getting your feedback once it's ready for consumption!
For my personal reference: this documentation may be helpful when designing an example with metering.
Hi @glennrfisher ,
Yes! currently I'm using the former SDK written in objective-c with some fixes by myself but it is deprecated unfortunately. So I want to shift to this new SDK. I will be able to work for this next week. I hope you will finish the merge this week!
Is there a way to use AVCaptureAudioDataOutputSampleBufferDelegate continuous listening version now with the current 0.1.1 release or do we need to wait for 0.2.0. Do you have an approximate ETA for 0.2.0?
Hi @siraustin. Unfortunately, it's been a bit delayed, since I was asked to help on a time-critical project last week. I just wrapped that up this afternoon, though, and will be back on the iOS SDK project starting tomorrow.
Sorry to all for the delays. I'm still trying to get this out as quickly as possible without sacrificing code quality.
Thanks, @glennrfisher -- helping out a group on an iOS project and really wanting to use Watson (continuous) SpeechToText... glad you're back on the project! I hope 0.2.0 comes soon :)
@glennrfisher is speech to text continuous listening known to be working in v0.1.1? I'm having trouble with it and don't want to bang my head too much if it's not known to be working... Thanks! [update I see the issue document in #147 -- it's not clear if it was resolved or closed in favor of the redesign]
@siraustin: Continuous listening is not working in v0.1.1. Sorry for the trouble.
Hi @glennrfisher, this is great work!
I've tested and found a bug in building url for websocket. Please check it out. https://github.com/watson-developer-cloud/ios-sdk/pull/198
Complete with 3fdc2746c754ba246137995e4f66231c3e8e9022
For those of you following this issue, I want to let you know that there is an example application to test and demonstrate the new Speech to Text implementation.
Please liberally open issues to let us know if you find any bugs! We will fix them quickly.
Transition the programming model from a delegate pattern to a completion handler pattern.
General API Functionality:
AVCaptureOutput
Requested Features:
Save sent audio as a file(See #185)Ensure completion handler is always called, even for silent audio.API Stub: