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

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

Closed
qcoumes opened this issue Feb 5, 2021 · 2 comments
Closed

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

qcoumes opened this issue Feb 5, 2021 · 2 comments

Comments

@qcoumes
Copy link

qcoumes commented Feb 5, 2021

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) :

mergedpath = str(os.path.join(tempfile.gettempdir(), "%s_merged.wav") % key)
subprocess.call(
[
settings.CAPTCHA_SOX_PATH,
"-r",
"8000",
"-n",
arbnoisepath,
"synth",
"2",
"brownnoise",
"gain",
"-15",
]
)
subprocess.call(
[
settings.CAPTCHA_SOX_PATH,
"-m",
arbnoisepath,
path,
"-t",
"wavpcm",
"-b",
"16",
mergedpath,
]
)
os.remove(arbnoisepath)
os.remove(path)
os.rename(mergedpath, path)

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"
@mbi
Copy link
Owner

mbi commented May 13, 2021

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 mbi closed this as completed Aug 25, 2022
@mbi
Copy link
Owner

mbi commented Dec 9, 2023

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 added a commit that referenced this issue Dec 3, 2024
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

2 participants