Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Port eSpeak NG to iOS 16, and expose it to VoiceOver using AVSpeechSynthesisProviderAudioUnit. #1291

Closed
robin24 opened this issue Aug 17, 2022 · 60 comments

Comments

@robin24
Copy link

robin24 commented Aug 17, 2022

Summary

iOS 16 Beta introduces AVSpeechSynthesisProviderAudioUnit, which should enable the integration of 3rd-party speech synthesizers into the VoiceOver screenreader, as well as Speak Screen and other assistive features that rely on speech synthesis.
With this in mind, it would be awesome if eSpeak NG, given its strong popularity within the screenreader community, could be ported to iOS and macOS.

Steps required to make this work

As far as I can tell, three main steps would be required to pull this off, with step 1 and 2 probably being the most work intensive:

  1. Port eSpeak NG to iOS - I've actually tried my hand at this, but don't know enough about C to fix all the compiler issues.
  2. Write a wrapper to make the ported version of eSpeak NG conform to AVSpeechSynthesisProviderAudioUnit.
  3. Build a simple SwiftUI app to manage active voices, and perhaps manage dictionaries that could be loaded directly into the synthesizer.
@XP-Fan
Copy link

XP-Fan commented Sep 9, 2022

Well please! Seriously I'll give 100 € (via PayPal), to the dev who makes this a reality provided he/she also manages to include the NVDA variants and the Libsonic or what it was called, so I can finally bring my iPhone's VoiceOver speech on par with the speed and low latency of my Windows XP computers.

@TheQuinbox
Copy link
Contributor

Hi @robin24,
How were you testing building this for iOS? I just built for Mac and it built flawlessly, and works. Should we get a basic AVAudioSpeechSynthesisUnitProvider working on MacOS Ventura (assuming it supports it), and then port it to iOS?

@parhamdoustdar
Copy link

parhamdoustdar commented Sep 13, 2022 via email

@robin24
Copy link
Author

robin24 commented Sep 13, 2022

Hey @TheQuinbox!

That's super cool, how did you get that to work?
I tried to approaches both of which failed for me:

  1. I followed the instructions for building on Linux / Mac / BSD found here, installing necessary dependencies via Homebrew:
    https://github.com/espeak-ng/espeak-ng/blob/master/docs/building.md
    For me that resulted in lots of compiler warnings / errors when running the make command, chances are this is because I'm on an M1 machine, are you on Intel or M1 as well?
  2. I also tried building with Xcode by following the instructions in this blog post: https://calebschoepp.com/blog/2021/compiling-espeak-ng-in-xcode-for-ios-app/.
    Unfortunately I got stuck with various errors suggesting that various files couldn't be located, but honestly this could be user error on my end as I've never tried anything like this in Xcode.

Getting this to work on macOS first sounds like the best approach though, as building for iOS probably requires some sort of cross compilation, I believe Xcode can do this or perhaps cmake on the command line as well, but that's probably a lot more involved I suppose.

@TheQuinbox
Copy link
Contributor

Hi @robin24,
I did the following:

  1. git clone --recursive espeak-ng/espeak-ng
  2. cd espeak-ng
  3. ./autogen.sh
  4. ./configure --prefix=/usr
  5. brew install automake
  6. make

I got a functional espeak lib that talks!

@XP-Fan
Copy link

XP-Fan commented Oct 16, 2022 via email

@nidza07
Copy link

nidza07 commented Oct 16, 2022

Hello,
I definitely also hope this can eventually happen.
For anybody interested to work on it, Apple has recently published documentation on how to use the new API to create a speech synthesizer:
https://developer.apple.com/documentation/avfaudio/audio_engine/audio_units/creating_a_custom_speech_synthesizer?language=objc

@mjonsson1986
Copy link

sinz the creator dont care about sapi. the hopes are small

@XP-Fan
Copy link

XP-Fan commented Oct 19, 2022 via email

@djphoenix
Copy link
Collaborator

I can contribute to this issue and provide iOS/macOS framework that wraps espeak-ng into AVSpeechSynthesisProviderAudioUnit. But, for sure, espeak-ng is GPL-licensed, so somewho should open and maintain entire project source, including wrapper and configuration UI. And so maintain AppStore release if and when it come out officially.

@XP-Fan
Copy link

XP-Fan commented Oct 25, 2022 via email

@djphoenix
Copy link
Collaborator

The first attempt to build swift package with libsonic and libespeak-ng was successful. Let's start a wrapper.

@XP-Fan
Copy link

XP-Fan commented Oct 27, 2022 via email

alex19EP added a commit that referenced this issue Oct 28, 2022
So we can ship data bundle and compile it AOT.

Helps to make #1291
alex19EP added a commit that referenced this issue Oct 28, 2022
On e.g. iOS it may be very long.

Helps to make #1291
@djphoenix
Copy link
Collaborator

Looks like test app working. Will upload initial version after some cleanup...

image

@mjonsson1986
Copy link

mjonsson1986 commented Oct 28, 2022 via email

@XP-Fan
Copy link

XP-Fan commented Oct 28, 2022 via email

@XP-Fan
Copy link

XP-Fan commented Oct 28, 2022 via email

@mjonsson1986
Copy link

@ XP-Fan thats because i answer by email in thunderbird

@djphoenix
Copy link
Collaborator

djphoenix commented Oct 28, 2022

and your paypal if it works.

I not do it for money but for idea. Open source software should help people. I have received many messages with thanks from blind people, it's unusual, it's... pleasant?)

If it does matter, send a donation to any fund (medical or open-source) for your choice.

@mjonsson1986
Copy link

please give me an test flight link when it is ready

@djphoenix
Copy link
Collaborator

please give me an test flight link when it is ready

Of course

@mjonsson1986
Copy link

eh? i assume this is for mac too?

@XP-Fan
Copy link

XP-Fan commented Oct 28, 2022 via email

@robin24
Copy link
Author

robin24 commented Oct 28, 2022

Hey,

Sorry I haven't commented here for a while, been busy job hunting and so I needed to put this on the back burner for some time.
@djphoenix Wow, thanks so much for taking this up! Your progress with this sounds really awesome, I'd be more than happy to join in on helping with the wrapper and developing a SwiftUI interface for setup and config if you like.
I somehow failed to get this to build on my M1 machine even with @TheQuinbox's instructions, but it sounds like you were able to wrap this inside of a Swift package so hopefully I'll have more luck with that.

Thanks again for your wonderful work Yuri and I hope we get to work together on this cool project.

@robin24
Copy link
Author

robin24 commented Oct 30, 2022

@djphoenix wow, amazing news!

Is your code already in a public repo somewhere?
Would love to build this locally to give it a spin, also curious to see what you did to get Xcode to build all the libraries - like I said this is something I've never done before personally so this makes for a great learning opportunity :-).

@djphoenix
Copy link
Collaborator

@robin24 of course, all code is open now.
See https://github.com/espeak-ng/espeak-ng-ios-app and https://github.com/espeak-ng/espeak-ng-spm repositories.

@mjonsson1986
Copy link

hope the app can be running on both mac and ios?

@djphoenix
Copy link
Collaborator

djphoenix commented Oct 30, 2022

It work on macOS, but voiceover extension is only since 13.0 which supported with XCode 14.1. Unfortunately it is not released yet, it is still RC2. I can't install it because I need production (stable) environment on small macbook SSD...

I will test and release macOS app as xcode 14.1 release happens.

@mjonsson1986
Copy link

why release 2 separate apps? mac os 11 and above can runios apps.. or do you meen 2 separate: 1 for m1 mac and ios. and 1 for intel maybe

@robin24
Copy link
Author

robin24 commented Oct 30, 2022

Hey @djphoenix,

Thanks so much for setting up the repos and sharing the links here!

I've now cloned the project, changed the team and bundle ID in Xcode to match with my own dev account details and now I'm able to build and run the app, yay!

However, I'm running into an entitlement error when trying to synthesize text with the following in the debugger:

container_create_or_lookup_app_group_path_by_app_group_identifier: client is not entitled
Error Domain=EspeakErrorDomain Code=268438271 "(null)"

Looking through the list of entitlements I can only find some related to macOS Sandbox, when you have a sec could you let me know which entitlements you included in the project so I can check what got lost?

Thanks!

@djphoenix
Copy link
Collaborator

@robin24 I think that this is because app groups that needed to exchange data between app and extension. Try to change identifiers and recover signing via xcode.

@djphoenix
Copy link
Collaborator

why release 2 separate apps? mac os 11 and above can runios apps.. or do you meen 2 separate: 1 for m1 mac and ios. and 1 for intel maybe

I'm not sure how iOS app extension will work on macOS. Also Intel macs are wide used. And I think that separate app is better anyway.

@robin24
Copy link
Author

robin24 commented Oct 30, 2022

@djphoenix Right, what's weird though is I already did that and set up the app groups for the main app as well as the extension, yet I keep running into this entitlement error...
I've already tried making a clean build and cleaning out my derrived data folder without any luck, I'll keep digging then.

@djphoenix
Copy link
Collaborator

Make sure to update UserDefault's ID according to your app group

@robin24
Copy link
Author

robin24 commented Oct 30, 2022

@djphoenix Ah yes, found the issue!

There are a couple hardcoded references to "group.dj.phoenix.espeak-ng" in the code, once I changed them for my group identifier it all worked as expected, awesome!!!

It would probably be best to change that code to construct the correct ID from the current bundle identifier at runtime so that it doesn't need to be changed manually when someone other than you wants to build this locally, I can take a look at that.

@djphoenix
Copy link
Collaborator

djphoenix commented Oct 30, 2022

There are a couple hardcoded references… It would probably be best to change that code…

K’mon, guys, that’s first working version, and make it work well is long roadmap. Keep in mind that it’s one week old. Of course I will clean it up and update.

I can take a look at that.

As always, PRs are welcome )

@djphoenix
Copy link
Collaborator

djphoenix commented Oct 30, 2022

That becomes a chat… since we have separate repository with iOS app, maybe we should move a discussions to its “issues”, right?

@robin24
Copy link
Author

robin24 commented Oct 30, 2022

@djphoenix Sorry, I wasn't trying to come across as impatient or criticizing your work in any way, only pointed this out because it's somewhat hard to catch when building the project for the first time, plus the debugger isn't helpful either in this case and just shows an entitlement error without much context.

I think it's really impressive how far this has come in a super short time, even including support for all the languages and voices that the synthesizer supports as far as I can tell.

Also you're right that we should move further discussion to the new repos, let's maybe keep this one around until the TestFlight submission is approved so we can share the link with everyone following along.

Again, sorry for the misunderstanding!

@djphoenix
Copy link
Collaborator

Oh, of course all OK. My english isn't perfect, and I never want to offend anyone. We all are doing the things to get the open world better.

@djphoenix
Copy link
Collaborator

Let the show begin.

https://testflight.apple.com/join/Q3zQlq47

@codeofdusk
Copy link
Contributor

Let the show begin.

Wow, that's great! @jwoo-msft and I tried our hand at porting this a while back. We got it running in a test app (as you did) but didn't get the system/VoiceOver integration going.

I've installed your testFlight app, but eSpeak doesn't appear in VoiceOver settings. Is it supposed to at this point?

@nidza07
Copy link

nidza07 commented Oct 31, 2022

@codeofdusk I had exactly the same issue as you at first, but I did the following and that caused it to appear.
First of all, I of course opened the ESpeak NG app and accepted the TestFlight warnings/activated the start testing button.
I assume you did that already, but it still didn't appear for me.
However, I restarted my phone, and then it appeared in VoiceOver settings.
You should see it under any language that is supported, there should be an ESpeak NG section with all the variants.

There are some bugs I will report later after additional testing, but globally, this is awesome! Thanks so much @djphoenix

@codeofdusk
Copy link
Contributor

@nidza07 I've tried rebooting several times, but it still isn't displayed.

@nidza07
Copy link

nidza07 commented Oct 31, 2022

Sorry that didn't help, you must be running into a different problem in that case. The only thing worth pointing out is that the API is iOS 16 exclusive, but I am assuming you're already aware of that.

Hopefully a solution is found...

@nidza07
Copy link

nidza07 commented Oct 31, 2022

It seems that this is indeed currently a little buggy. After using it for a while, my ESpeak also completely disappeared, but for me it was enough to open the ESpeak NG app again and it appeared once more.

@mjonsson1986
Copy link

this app installs on m1 mac. but no voices show up in voiceover

@djphoenix
Copy link
Collaborator

@mjonsson1986 keep patient for a bit, I think xCode 14.1 will be released in this week, and I complete a port.

@djphoenix
Copy link
Collaborator

@codeofdusk @nidza07 here a some bugs of course, and I have caught your issue with missing voiceover... once. I can't reproduce and so debug it...

I think a lot of bugs will disappear after code cleanup and refactoring.

@djphoenix
Copy link
Collaborator

I notes all discussions in iOS project issues. As TestFlight available now, I think that we may close this one.

@willwade
Copy link

willwade commented Jan 4, 2024

Nudge: its been done but I can't see this in the current live version of the app.. just saying - it would be helpful if someone would update it :)

@nidza07
Copy link

nidza07 commented Jan 4, 2024

@willwade The current version of the application works fine for me. Sometimes after the first installation it may take a few minutes for the voice to show though, but as long as you enabled the language you want inside VoiceOver languages section of the app, you should see the ESpeak voices under that language in either VoiceOver or spoken content accessibility settings, depending on what you want to use it for.

@XP-Fan
Copy link

XP-Fan commented Jan 5, 2024 via email

@willwade
Copy link

willwade commented Jan 5, 2024

@willwade The current version of the application works fine for me. Sometimes after the first installation it may take a few minutes for the voice to show though, but as long as you enabled the language you want inside VoiceOver languages section of the app, you should see the ESpeak voices under that language in either VoiceOver or spoken content accessibility settings, depending on what you want to use it for.

Well my bad! I do apologise! it is a bit, well flaky, at times. (it seems to work better in third party apps than apples own Speak Content settings..). Awesome stuff. Thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants