Page 4 of 9
Re: Convert Label text to LRC file
Posted: Sun Mar 01, 2020 12:12 pm
by bigboss97
I modified the code and write the output to a binary file:
Code: Select all
write_json = open('labels.json', 'wb')
*snip*
while (last != b'\n' or line != b'\n'):
last = line
line = read_pipe.read(1)
print(line.hex(), end=' ')
write_json.write( line)
It still shows me the wxwidgets path:
Code: Select all
0.452789 0.452789 hello
1.044898 1.044898 小苹果

Re: Convert Label text to LRC file
Posted: Sun Mar 01, 2020 2:00 pm
by steve
This will return the byte values (This version is for Linux and will need adapting for Windows)
Code: Select all
import os
import sys
PIPE_BASE = '/tmp/audacity_script_pipe.'
WRITE_NAME = PIPE_BASE + 'to.' + str(os.getuid())
READ_NAME = PIPE_BASE + 'from.' + str(os.getuid())
EOL = '\n'
write_pipe = open(WRITE_NAME, 'w')
read_pipe = open(READ_NAME, 'rb')
def send_command(command):
"""Send a single command."""
print("Send: >>> \n"+command)
write_pipe.write(command + EOL)
write_pipe.flush()
def get_response():
"""Return the command response."""
eolCount = 0
bytes = bytearray([])
while eolCount < 2:
byte = read_pipe.read(1)
bytes += byte
if byte == b'\n' :
eolCount +=1
else:
eolCount = 0
print(bytes.hex())
send_command("GetInfo: Type=Labels")
get_response()
The problem though is that the returned bytes may not all be valid UTF-8, so I don't know how you would decoded it.
Re: Convert Label text to LRC file
Posted: Tue Mar 03, 2020 2:59 am
by bigboss97
Following
pipe_test.py code adapted:
Code: Select all
WRITE_NAME = '\\\\.\\pipe\\ToSrvPipe'
READ_NAME = '\\\\.\\pipe\\FromSrvPipe'
EOL = '\r\n\0'
This is my output. You still can see 4 zero bytes followed by the path "633a5c777877696467...", just like the last time I tried.
Code: Select all
C:\tmp>python get-labels.py
Send: >>>
GetInfo: Type=Labels
5b200a20205b20312c0a202020205b200a2020202020205b20302e3837303734382c20302e383730
3734382c202268656c6c6f22205d2c0a00000000633a5c7778776964676574732d332e312e315c69
6e636c7564655c77785c7374727661724261746368436f6d6d616e642066696e69736865643a204f
4b0a0a
Re: Convert Label text to LRC file
Posted: Tue Mar 03, 2020 11:08 am
by steve
bigboss97 wrote: ↑Tue Mar 03, 2020 2:59 am
This is my output. You still can see 4 zero bytes followed by the path "633a5c777877696467...", just like the last time I tried.
What output do you get from two labels, each containing: 不要你
What output do you get from the "GetInfo" menu command with those labels?
Re: Convert Label text to LRC file
Posted: Tue Mar 03, 2020 11:33 am
by bigboss97
steve wrote: ↑Tue Mar 03, 2020 11:08 am
What output do you get from two labels, each containing: 不要你
What output do you get from the "GetInfo" menu command with those labels?

The arrow is pointing at the path.
Re: Convert Label text to LRC file
Posted: Tue Mar 03, 2020 11:38 am
by steve
I'm trying to work out where the encoding / decoding is going wrong.
I can't copy and paste digits from a screenshot.
Re: Convert Label text to LRC file
Posted: Tue Mar 03, 2020 11:47 am
by bigboss97
Code: Select all
5b200a20205b20302c0a202020205b200a2020202020205b20302e3333363638392c20302e3333363638392c202248656c6c6f22205d2c0a00000000633a5c7778776964676574732d332e312e315c696e636c7564655c77785c7374727661724261746368436f6d6d616e642066696e69736865643a204f4b0a0a
Code: Select all
[
[ 0,
[
[ 0.336689, 0.336689, "Hello" ],
[ 2.15946, 2.15946, "小苹果" ] ] ] ]
Re: Convert Label text to LRC file
Posted: Tue Mar 03, 2020 11:51 am
by bigboss97
bigboss97 wrote: ↑Sun Mar 01, 2020 12:12 pm
Code: Select all
0.452789 0.452789 hello
1.044898 1.044898 小苹果
Just like my old post (above), there are 4x zero bytes then followed by a path.
Re: Convert Label text to LRC file
Posted: Tue Mar 03, 2020 4:45 pm
by steve
You're getting less on Windows than I do on Linux. Your version appears to be completely choking on the Unicode characters.
For the current version of Audacity, it appears that the script pipe module does not support Unicode at all on Windows. I've written to the developers about this, but I'm not hopeful of Unicode support being added any time soon, unless the problem was just an oversight that can be easily fixed.
I'll write back if I get more information. Sorry I couldn't be more help.
Re: Convert Label text to LRC file
Posted: Tue Mar 03, 2020 9:28 pm
by bigboss97
Thank you for your time
