bug 2.3.2 mod-script-pipe
Forum rules
This board is ONLY for general feedback and discussion about Audacity 2.X.
If you require help, or think you have found a "bug", please post on the forum board relevant to your operating system.
Windows
Mac OS X
GNU/Linux and Unix-like
This board is ONLY for general feedback and discussion about Audacity 2.X.
If you require help, or think you have found a "bug", please post on the forum board relevant to your operating system.
Windows
Mac OS X
GNU/Linux and Unix-like
bug 2.3.2 mod-script-pipe
I use audacity with mod-script-pipe, and noticed this issue because on my ubuntu audacity started with interface in Romanian language.
But I have the same behavior on windows, if I switch the language of the Interface between english and romanian.
I import a track in audacity and read using a python script the tracks
TOPIPE.write('GetInfo: Type=Tracks' + EOL)
With language=English I get this:
[
{ "name":"radio", "focused":0, "selected":1, "kind":"wave", "start":0, "end":30.0466, "pan":0, "gain":1, "channels":1, "solo":0, "mute":0, "VZoomMin":-1, "VZoomMax":1 } ]
BatchCommand finished: OK
with language=Romanian I get this
{ "name":"radio", "focused":0, "selected":1, "kind":"wave", "start":0, "end":30,0466, "pan":0, "gain":1, "channels":1, "solo":0, "mute":0, "VZoomMin":-1, "VZoomMax":1 }]
BatchCommand finished: OK
The difference between the two is in this part
english ------> "end":30.0466
romanian --------> "end":30,0466
The comma (,) is used as a decimal separator in romanian.
This trigger error during json.loads()
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes:
I think the easiest fix would be to enclose the value in double quotes.
Thanks
But I have the same behavior on windows, if I switch the language of the Interface between english and romanian.
I import a track in audacity and read using a python script the tracks
TOPIPE.write('GetInfo: Type=Tracks' + EOL)
With language=English I get this:
[
{ "name":"radio", "focused":0, "selected":1, "kind":"wave", "start":0, "end":30.0466, "pan":0, "gain":1, "channels":1, "solo":0, "mute":0, "VZoomMin":-1, "VZoomMax":1 } ]
BatchCommand finished: OK
with language=Romanian I get this
{ "name":"radio", "focused":0, "selected":1, "kind":"wave", "start":0, "end":30,0466, "pan":0, "gain":1, "channels":1, "solo":0, "mute":0, "VZoomMin":-1, "VZoomMax":1 }]
BatchCommand finished: OK
The difference between the two is in this part
english ------> "end":30.0466
romanian --------> "end":30,0466
The comma (,) is used as a decimal separator in romanian.
This trigger error during json.loads()
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes:
I think the easiest fix would be to enclose the value in double quotes.
Thanks
Re: bug 2.3.2 mod-script-pipe
Thanks for the report.
There's several other places this occurs too, such as clip start / end times, vertical zoom, and several others.
A possible solution would be for each occurrence (in the Audacity code), to wrap the values in:
Example:
Now
With "Internat::ToString"
Would that solve the problem for you?
There's several other places this occurs too, such as clip start / end times, vertical zoom, and several others.
A possible solution would be for each occurrence (in the Audacity code), to wrap the values in:
Code: Select all
Internat::ToString(<value>)Now
Code: Select all
[
{ "name":"Audio Track", "focused":1, "selected":1, "kind":"wave", "start":0, "end":29,3854, "pan":0, "gain":0,281838, "channels":1, "solo":0, "mute":0, "VZoomMin":-1, "VZoomMax":1 } ]
Code: Select all
[
{ "name":"Audio Track", "focused":1, "selected":1, "kind":"wave", "start":0, "end":"29.385397", "pan":0, "gain":0,281838, "channels":1, "solo":0, "mute":0, "VZoomMin":-0,461539, "VZoomMax":0,769231 } ]
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
Re: bug 2.3.2 mod-script-pipe
I recall that you build Audacity yourself, so here's the fix if you wish to modify your version of Audacity.
In each case in GetInfoCommand.cpp where you see a line:
rewrite the line as:
For example, in bool GetInfoCommand::SendTracks(const CommandContext & context)
change:
to:
In each case in GetInfoCommand.cpp where you see a line:
Code: Select all
context.AddItem( <floating point value> );Code: Select all
context.AddItem( Internat::ToString(<floating point value>) );change:
Code: Select all
context.AddItem( "wave", "kind" );
context.AddItem( t->GetStartTime(), "start" );
context.AddItem( t->GetEndTime(), "end" );
Code: Select all
context.AddItem( "wave", "kind" );
context.AddItem( Internat::ToString(t->GetStartTime()), "start" );
context.AddItem( Internat::ToString(t->GetEndTime()), "end" );
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
Re: bug 2.3.2 mod-script-pipe
I made those changes, and how the times are quoted.
Thanks for the response.
Regards,
Razvan
Thanks for the response.
Regards,
Razvan
Re: bug 2.3.2 mod-script-pipe
The "solution" that I proposed in my previous post has disadvantages for Nyquist Macros, but hopefully it's sufficient for you in the short term.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
Re: bug 2.3.2 mod-script-pipe
Here's a better fix.
This retains the dot as the decimal separator, but does not quote the numeric values, so it does not interfere with Nyquist.
This retains the dot as the decimal separator, but does not quote the numeric values, so it does not interfere with Nyquist.
Code: Select all
diff --git a/src/commands/CommandTargets.cpp b/src/commands/CommandTargets.cpp
index 490d3fb..c171827 100644
--- a/src/commands/CommandTargets.cpp
+++ b/src/commands/CommandTargets.cpp
@@ -32,6 +32,9 @@ capture the more lengthy output from some commands.
#include "../widgets/AudacityMessageBox.h"
#include "../widgets/wxPanelWrapper.h"
+#include <locale>
+#include <sstream>
+
void CommandMessageTarget::StartArray()
{
wxString Padding;
@@ -78,11 +81,18 @@ void CommandMessageTarget::AddBool(const bool value, const wxString &name){
Update( wxString::Format( "%s\"%s\":\"%s\"", (mCounts.back()>0)?", ":"", name,value?"true":"false"));
mCounts.back() += 1;
}
+
void CommandMessageTarget::AddItem(const double value, const wxString &name){
+ std::stringstream str;
+ std::locale nolocale("");
+ str.imbue(nolocale);
+
if( name.empty() )
- Update( wxString::Format( "%s%g", (mCounts.back()>0)?", ":"", value));
+ str << ((mCounts.back()>0)? ", " : "") << value;
else
- Update( wxString::Format( "%s\"%s\":%g", (mCounts.back()>0)?", ":"", name,value));
+ str << ((mCounts.back()>0)? ", " : "") << "\"" << name << "\"" << ":" << value;
+
+ Update( str.str() );
mCounts.back() += 1;
}
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
Re: bug 2.3.2 mod-script-pipe
yes, by putting the float values between double quotes, solved it for me.
(I don't use Nyquist)
Thanks for the prompt help Steve
(I don't use Nyquist)
Thanks for the prompt help Steve