rsavageatx
(Richard Savage)
July 30, 2022, 4:44am
1
I am new to Mathematica and have just started to use its Audio features. When I evaluate
recording = AudioRecord[]
I get this error message “AudioRecord: An internal error occurred: the file could not be opened.”
What do I need to do to keep from getting this error?
rsavageatx
(Richard Savage)
August 1, 2022, 10:47pm
2
After digging through the Mathematica documention I was able to solve my problem using the following code:
NBDIR = NotebookDirectory[];
SetDirectory[NBDIR];
FILENAME = "rec2.wav";
FE = FileExistsQ[FILENAME];
if[FE, , DeleteFile[FILENAME]];
REC = AudioRecord[$DefaultAudioInputDevice,
GeneratedAssetLocation -> FILENAME];
AudioStop[REC];
AudioRecord[REC, MaxDuration -> 5.0]
This
if[FE, , DeleteFile[FILENAME]];
should be
If[FE, DeleteFile[FILENAME]];
WL built-in symbols start with an uppercase letter. Better to avoid using symbol names that start with an uppercase letter to avoid potential conflicts.
rsavageatx
(Richard Savage)
August 3, 2022, 3:31am
4
I didn’t realize WL built-in symbols always start with an uppercase. So I agree with your suggestion.
Also, thanks for correcting my “If statement”.