PiRSquared17 / winpython

Automatically exported from code.google.com/p/winpython
0 stars 0 forks source link

python scikits.audiolab Sndfile special chars in file name #104

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. just run the bellow code 

What is the expected output? 
Audio .Wav file detail information 

What do you see instead?
Get an error
  File "D:/python/Interstitial Project/test.py", line 9, in <module>
    track_one_file_obj = Sndfile(track1, 'r')
  File "_sndfile.pyx", line 488, in scikits.audiolab.pysndfile._sndfile.Sndfile.__init__ (scikits\audiolab\pysndfile\_sndfile.c:4251)
IOError: error while opening C:\Users\Furqan\Desktop\test\查找問題daw\1.wav
    ->error while opening file C:\Users\Furqan\Desktop\test\查找問題daw\1.wav
    -> System error : The system cannot find the path specified.

What version of the product are you using? On what operating system?

Please provide any additional information below.
Hi ,

I am trying to get a wav file information but Sndfile is unable to read file 
with special characters in path and file name(查找問題daw.wav) and i am 
unable to get information in any way , i tried passing file path to Sndfile  
with diferent encoding to but didnt work , but if i pass this 
'C:\Users\Furqan\Desktop\test\DAW\1.wav' it works fine , Thanks is advance 

My Code is 
# -*- coding: UTF-8 -*-
from scikits.audiolab import Sndfile
from os import walk, path, stat

track1 =  r'C:\Users\Furqan\Desktop\test\查找問題daw\查找問題d.wav'
#track2 = r'C:\Users\Furqan\Desktop\test\DAW\1.wav'

#try:
track_one_file_obj = Sndfile(track1, 'r')
#except:
#    print('Simple didnt work')
#    pass

try:
    track_one_file_obj = Sndfile(track1.decode('cp1252'), 'r')
except:
    print('cp1252 didnt work')
    pass

try:
    track_one_file_obj = Sndfile(track1.encode('utf-8'), 'r')
    print(track_one_file_obj)
except:
    print('encode didnt work')
    pass

try:
    track_one_file_obj = Sndfile(track1.encode('utf8'), 'r')
    print(track_one_file_obj)
except:
    print('encode didnt work')
    pass

try:
    track_one_file_obj = Sndfile(track1.decode('utf-8'), 'r')
    print(track_one_file_obj)
except:
    print('decode didnt work')
    pass

Original issue reported on code.google.com by fur...@geekschicago.com on 18 Aug 2014 at 12:35