VoiceStudio is the open-source, fully-local ElevenLabs alternative — voice cloning, voice design, video dubbing, dictation, transcription & audiobook creation in 646 languages.
Python aiaudiobookcudadubbingelevenlabs-alternativehuggingfacelocal-firstmlxomnivoice-studiospeech-to-texttext-to-speechtranscriptiontranslatettsvoice-aivoice-cloningvoice-generationvoicestudioworkflow
fix(ios): downmix stereo microphone input for dictation
debpalash61e4440c0a18
diff --git a/.github/workflows/mobile.yml b/.github/workflows/mobile.ymlindex 0afd42d79..51bdd73fa 100644--- a/.github/workflows/mobile.yml+++ b/.github/workflows/mobile.yml@@ -152,6 +152,7 @@ jobs:-scheme VoiceStudioNative -destination "id=$SIM_UDID" \'-only-testing:VoiceStudioKitTests/phoneVideoMuxPreservesOrientationAndMarksPlayableAudio()' \'-only-testing:VoiceStudioKitTests/phoneDubPlaybackRestoresPlaybackAfterDictation()' \+ '-only-testing:VoiceStudioKitTests/phoneDictationConverterKeepsRightStereoChannel()' \-parallel-testing-enabled NO CODE_SIGNING_ALLOWED=NO test# ScreenshotTour keeps a screenshot of every screen; export them for review.- name: Export UI screenshotsdiff --git a/CHANGELOG.md b/CHANGELOG.mdindex 1ea85b655..8be3b237b 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -31,7 +31,7 @@ metadata and the backend fallback mirror it.### Fixed- Phone dub playback restores sound after dictation on iOS and keeps the video visible when switching results on Android (#2969)-- Stereo WAV, CAF and AIFF references keep both channels when converted to mono on iOS (#2969)+- Stereo reference files and dictation inputs keep both channels when converted to mono on iOS (#2969)- Android dubbing errors remain visible when worker updates arrive while their receipt is being saved (#3031)- iOS reserves storage across simultaneous model downloads and keeps saved speech paired with the submitted text (#2969)diff --git a/mobile/ios/VoiceStudio/Platform/DictationAudio.swift b/mobile/ios/VoiceStudio/Platform/DictationAudio.swiftindex 733382897..60c7139c3 100644--- a/mobile/ios/VoiceStudio/Platform/DictationAudio.swift+++ b/mobile/ios/VoiceStudio/Platform/DictationAudio.swift@@ -36,10 +36,10 @@ import VoiceStudioKit}}/// The converter is confined to AVAudioEngine's serial audio callback.-private final class PCMConverter: @unchecked Sendable {+final class PCMConverter: @unchecked Sendable {let converter: AVAudioConverterlet output: AVAudioFormat- init(converter: AVAudioConverter, output: AVAudioFormat) { self.converter = converter; self.output = output }+ init(converter: AVAudioConverter, output: AVAudioFormat) { self.converter = converter; self.output = output; converter.downmix = true }func convert(_ input: AVAudioPCMBuffer) throws -> Data {let capacity = AVAudioFrameCount(ceil(Double(input.frameLength) * 16000 / input.format.sampleRate)) + 32guard let result = AVAudioPCMBuffer(pcmFormat: output, frameCapacity: capacity) else { throw ClientError("mobile.errors.audio") }diff --git a/mobile/ios/VoiceStudioKit/Tests/VoiceStudioKitTests/PhonePlaybackTests.swift b/mobile/ios/VoiceStudioKit/Tests/VoiceStudioKitTests/PhonePlaybackTests.swiftindex d4f0cfc8d..4956df0da 100644--- a/mobile/ios/VoiceStudioKit/Tests/VoiceStudioKitTests/PhonePlaybackTests.swift+++ b/mobile/ios/VoiceStudioKit/Tests/VoiceStudioKitTests/PhonePlaybackTests.swift@@ -14,4 +14,22 @@ import Testing#expect(session.mode == .default)#expect(player.currentItem != nil)}++@Test @MainActor func phoneDictationConverterKeepsRightStereoChannel() throws {+ let input = try #require(AVAudioFormat(commonFormat: .pcmFormatFloat32, sampleRate: 48000, channels: 2, interleaved: false))+ let output = try #require(AVAudioFormat(commonFormat: .pcmFormatInt16, sampleRate: 16000, channels: 1, interleaved: true))+ let converter = try #require(AVAudioConverter(from: input, to: output))+ let pcm = PCMConverter(converter: converter, output: output)+ let buffer = try #require(AVAudioPCMBuffer(pcmFormat: input, frameCapacity: 4800))+ buffer.frameLength = 4800+ let channels = try #require(buffer.floatChannelData)+ for frame in 0..<4800 {+ let phase = Double(frame) * 2.0 * Double.pi * 440.0 / input.sampleRate+ channels[0][frame] = 0+ channels[1][frame] = Float(sin(phase) * 0.4)+ }+ let audio = try pcm.convert(buffer)+ #expect(!audio.isEmpty)+ #expect(audio.contains { $0 != 0 })+}#endif