sillsdev / SpeechAnalyzer

SIL Speech Analyzer is a Windows program for acoustic analysis of speech sounds.
https://software.sil.org/speech-analyzer/
7 stars 3 forks source link

bug: Error on "Save As" with mp3 file #49

Closed megahirt closed 2 years ago

megahirt commented 2 years ago

There's not yet enough information here to reproduce, but I'm creating an issue here to track this post.

https://community.software.sil.org/t/why-cannot-i-save-my-sa-audio/5380

@terrygibbs can you try and reproduce the error and offer some more explanation in this issue and on the community site? Thanks.

darcywong00 commented 2 years ago

My steps to reproduce the error:

  1. Rename an mp3 file to use a long name as reported https_psv4.userapi.com_c538232u366021368_audiomsg_d23_a40be394af.mp3
  2. In SA, open the mp3 file
  3. Then File --> Save As generates the error prompt
darcywong00 commented 2 years ago

In discussing with @terrygibbs , he pointed out that SA natively processes wav files. While SA can open mp3 files, it's "read-only", so we should disable "Save As".

To convert from mp3 to wav file, follow the "Paste as New File" steps. I'll add a troubleshooting help file for this in #53

kgorham commented 2 years ago

I looked at the code for this problem. Internally, SA will be working on a temporary .wav file. When SaveAs is used the code checks to see if it's using a temp .wav file, but the variable for that indicator isn't set - even though the .mp3 has been read in and the tmp .wav file does exists in the document. So it then decides that it must be a regular wav file and then blindly renames the extension and tries to open the file as a wav (yes, during the saveas). this fails, throws an exception which displays the error.

megahirt commented 2 years ago

Nice investigation, Kent!

What do you suggest as the fix?

kgorham commented 2 years ago

Internally, SA has already created a temporary wav file of the recording. I think we could just save that. I will play with that and send a sample of the output. The user wont have control over the parameters of the wav file (e.g. hz). It will created according to SAs settings. (This also assumes the entire file is saved, not a portion). If we only want to save a portion, then Darcys suggested flow needs to happen. As an alternative, maybe there could be an 'Export As', where as 'Save As' implies the original file format is retained, and 'Export As' implies the format will be changed. Just listing some ideas. no guarantee they are 'good' ideas.

kgorham commented 2 years ago

Capturing email from Terry to Darcy:

Darcy, SA can open a MP3 file, but when a user tries to save the file, then SA shows dialog box like this: image This was by design as of June 2005. . MP3 and WMA support (read-only access).

By now there needs to be an obvious way for a user to save MP3 files. My suggestion is to not gray out the "Save As..." option, but simply change the content of the popup dialog text above. image That is, let the user click on the "Save As..." and when the the dialog shows up, use this revised text to explain how to handle an MP3 file "Save As..." request. image This will create a .Wav file that SA can now save. Terry

darcywong00 commented 2 years ago

More historical background from @terrygibbs

As I have previously noted:

This was by design as of June 2005. . MP3 and WMA support (read-only access).

We wanted to make it a bit difficult for a user to convert an MP3 file because it does not 'fit' the kind of work that SA is designed to work with.

By definition a Wav file generates un-compressed audio data at a bit rate of 1,411 kbit/s Depending on how the MP3 recorder is configured, an MP3 file will loose from 5 to 10 times that amount of data per second.

MP3 is fine for recording music and listening to music, but the simple fact is that MP3 data is un-usable for Spectrogram and Formant Track use.

It was our experience that people would record their linguistic data in MP3 format and then convert it to Wav and then complain that SA did not accurately render the details they expected when doing their analysis work.

Thus we made it not so straight forward for users to convert MP3 to Wav. Linguists understand this situation, but novice users often miss this very important issue.

kgorham commented 2 years ago

@darcywong00 I tried your download link. Seemed to run fine. (uninstalled old SA and reinstalled new). As an improvement, I would suggest stealing some of the code that is in place already, and use the first part of the original filename for the new filename instead of using the .tmp filename. @terrygibbs can second that opinion or not...

image