django-simple-captcha icon indicating copy to clipboard operation
django-simple-captcha copied to clipboard

/usr/bin/sox FAIL sox: Input files must have the same sample-rate

Open qcoumes opened this issue 4 years ago • 1 comments

When trying to use audio Captcha, I get the following error from sox : /usr/bin/sox FAIL sox: Input files must have the same sample-rate.

It seems to be coming from the second call to sox (line 180) :

https://github.com/mbi/django-simple-captcha/blob/137fe973188ddd8feaaa58961ef9bce70eb5d7da/captcha/views.py#L165-L195

Since sox fails, line 195 raises a FileNotFoundError: on mergedpath.

Any way to solve this ?

I'm using django 3.1.6 with Python 3.9.1.

  • settings.py :
CAPTCHA_FONT_SIZE = 30
CAPTCHA_IMAGE_SIZE = (210, 50)
CAPTCHA_LENGTH = 8
CAPTCHA_FLITE_PATH = "/usr/bin/flite"
CAPTCHA_SOX_PATH = "/usr/bin/sox"

qcoumes avatar Feb 05 '21 14:02 qcoumes

Can't really reproduce, which version of flite and sox are you using?

This works for me (using your settings)

~ sox --version
sox:      SoX v14.4.2

~ flite --version
  Carnegie Mellon University, Copyright (c) 1999-2016, all rights reserved
  version: flite-2.1-release Dec 2017 (http://cmuflite.org)

mbi avatar May 13 '21 12:05 mbi

Hello @qcoumes I was just bit by this issue myself. It seems to me the same version of flite sometimes outputs PCM Wave at 8kHz (on e.g. Debian), and sometimes at 16kHz (on e.g. Arch). Do you happen to remember which how you had tested?

mbi avatar Dec 09 '23 19:12 mbi