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

WhisperAudioconvert return Permission denied in Android #22

Open
zackattack73 opened this issue Aug 7, 2023 · 2 comments
Open

WhisperAudioconvert return Permission denied in Android #22

zackattack73 opened this issue Aug 7, 2023 · 2 comments

Comments

@zackattack73
Copy link

When using WhisperAudioconvert.convert() to convert the file to a wav file i got this error :

Unhandled Exception: ProcessException: Permission denied

My audio file is in the assets folder.
What I have try so far :

  • Add and ask for the storage permission
  • Use getTemporaryDirectory() / getApplicationDocumentsDirectory() for the audio output path
  • Create a copy of the audio file from asset in tempDirectory / ApplicationDirectory
  • Create a new directory in ApplicationDirectory and use this in the path

So far none of this work and I still have the error. Any idea of what I could do ?

Full Code & error (Here I made a copy of the file from asset to a new directory called debugwhisper in the ApplicationDirectory) :

      Directory appDocumentsDirectory = await getApplicationDocumentsDirectory();
      String appDocumentsPath = appDocumentsDirectory.path;
      Directory dir = await Directory('$appDocumentsPath/debugwhisper').create(recursive: true);
      var status = await Permission.storage.request();
      final bytes = await rootBundle.load('assets/audio.mp3');
      final buffer = bytes.buffer;
      final newPathAudio = '${dir.path}/audio.mp3';
      await File(newPathAudio).writeAsBytes(
          buffer.asUint8List(bytes.offsetInBytes, bytes.lengthInBytes));
      print(status);
      Transcribe transcribe = await whisper!.transcribe(
        audio: WhisperAudioconvert.convert(
          audioInput: File(newPathAudio),
          audioOutput: File("${dir.path}/convertedAudio.wav"),
        ).path,
        model: pathModel,
        language: lang, // language
      );

E/flutter ( 5261): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: ProcessException: Permission denied E/flutter ( 5261): Command: ffmpeg -i /data/user/0/com.example.whisper_poc/app_flutter/debugwhisper/audio.mp3 -ar 16000 -ac 1 -c:a pcm_s16le /data/user/0/com.example.whisper_poc/app_flutter/debugwhisper/convertedAudio.wav

@jeffysmak
Copy link

jeffysmak commented Oct 10, 2023

Hi, can you please guide me its setup instructions, is there any extra step to place somewhere libwhisper.so file? i am getting error - Invalid argument(s): Failed to load dynamic library 'libwhisper.so': dlopen failed: library "libwhisper.so" not found

Whisper w = Whisper();
Version v = await w.getVersion();
print(v?.rawData);

this is what currently i am doing but not working

@lrq3000
Copy link

lrq3000 commented Oct 13, 2023

You are likely stumbling in Android SAF storage management system which is a hassle to get working. Yiu can instead use SimpleStorage which is very easy to use. This should allow your app to get the permissions it needs to.access files anywhere in the system (the user needs to be asked to grant permission for any change of location.

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

No branches or pull requests

3 participants