Praat script, extract intensity - praat

here is my script so far:
subject$ = "1307_2014_Feb_11_1153LDAlong\"
directory$ = "E:\data\speech\MMN\" +subject$
writeInfoLine ("Reading directory ",directory$)
strings = do ("Create Strings as file list...", "fileList", subject$ + "*.wav")
numberOfFiles = do ("Get number of strings")
for ifile to numberOfFiles
selectObject (strings)
fileName$ = do$ ("Get string...", ifile)
writeInfoLine (fileName$)
something = do ("Read from file...", subject$ + fileName$)
selectObject ("Sound "+fileName$- ".wav")
select Intensity 'soundname$'
fileappend "'textfile$'" 'newline$'
Save as text file: "E:\data\speech\MMN\nat_int
endform
Any pointers? I can't get it to work.
I appreciate your help.
Goldie

In fact, I don't know what you want to do with your script, so I tried to revised your script which could write down the names of the intensity files you created.
form name
sentence subject 1307_2014_Feb_11_1153LDAlong\
sentence directory E:\data\speech\MMN\
endform
strings = do ("Create Strings as file list...", "fileList", subject$ + "\*.wav")
numberOfFiles = do ("Get number of strings")
for ifile to numberOfFiles
selectObject (strings)
fileName$ = do$ ("Get string...", ifile)
appendInfoLine (fileName$)
something = do ("Read from file...", subject$ +"\"+ fileName$)
selectObject (something)
intensity = do("To Intensity...", 100, 0, "yes")
name$ = selected$("Intensity")
appendFileLine("E:\data\speech\MMN\nat_int\name.txt", name$)
endfor`

Related

How does this loop works?

I have this code and I need to find an explanation to it especially the part
set files ="$files test$k.ppm"
what does it do?
set files = ""
set k = 100
while($k <210)
set files = "$files test$k.ppm"
# k = $k +10
end
https://explainshell.com/
set is for setting variables
This row set variable "files" into String with value as "{files} test{counter}.ppm"
files ="$files test$k.ppm"
At the beginning files is empty String...
#1st iteration (IN: files = "", k = 100)
files = "" + test100.ppm
#out files = test100.ppm
#2nd iteration (files = "" + test100.ppm; k = 110)
files = test100.ppm test110.ppm
#out files = test100.ppm test110.ppm
#Last iteration will be something like
test100ppm test110ppm {...} test200.ppm
Nothing else

Reading gibberish filename (FTP/FSO)

Looking at my server, i see filenames, that theur characters have been messed up.
Example: ôøùú-ô÷åãé-1.mp3
should should be Hebrew letters.
While the files can be read in a browser and FTP, they cannot be read always - for example, in an online audio player, or VBScript FSO (File system object)
is there something that can be done to change the charset or something, so that i can read and then rename these files?
Thanks!
solved, using this link: http://pastebin.com/yXRWDggY
function convertChar(letter)
lat = array("à","á","â","ã","ä","å","æ","ç","è","é","ê","ë","ì","í","î","ï","ð","ñ","ò","ó","ô","õ","ö","÷","ø","ù","ú", " " )
heb = array("א","ב","ג","ד","ה","ו","ז","ח","ט","י","ך","כ","ל","ם","מ","ן","נ","ס","ע","ף","פ","ץ","צ","ק","ר","ש","ת", " ")
inarray = false
for ii = 0 to ubound(heb)
if letter = heb(ii) then
convertChar = lat(ii)
inarray = true
exit for
end if
next
if inarray = false then convertChar = letter
end function

Strange behavioural difference between vbscript and jscript using ADODB.stream in an HTA application

VBscript example:
Function ADO_WriteToFile(FileURL,data)
Dim arrBytes
SET ADObj = CreateObject("ADODB.Stream")
ADObj.Open
ADObj.Charset = "iso-8859-1"
ADObj.Type = adTypeText
ADObj.WriteText data
ADObj.SaveToFile FileURL, adSaveCreateOverwrite
ADObj.Close
ADObj.Open
ADObj.Type = adTypeBinary
ADObj.LoadFromFile FileURL
ADObj.Position = 3
arrBytes = ADObj.Read
ADObj.Position = 0
ADObj.SetEOS
ADObj.Write data
ADObj.SaveToFile FileURL, adSaveCreateOverwrite
ADObj.Close
End Function
JScript example:
function writeTo(fileName,str) {
var ado = new ActiveXObject("ADODB.Stream");
ado.Type = 2;
ado.Open();
ado.Position = 0;
ado.WriteText(str,0);
ado.SaveToFile(fileName,2);
ado.Close();
ado.Open();
ado.Type = 1;
ado.Position = 2;//line 19
var temp = ado.Read();
ado.Position = 0;
ado.SetEOS;
ado.Write(temp);
ado.SaveToFile(fileName,2);
ado.Close();
}
Why does the VBScript example work perfectly except for the fact that it can't accept file paths with space in them?
The JScript example errors out with the message "assignment to the parameter is incorrect." line 19. This doesn't happen if I set Position to 0 however:
ado.Position = 0;
i am using this to write binary files to disk btw
Here are some differences:
In the VBScript version, position is set to 3; in the JScript version, it is set to 2
In the VBScript version, the character set is defined; in the JScript version, it is undefined
In the VBScript version, WriteText and write both reference the argument; in the JScript version, only WriteText references it
References
Use vs Mention in JScript doesn't come for Free
JScript Data Types: Data Type Summary

Windows command-line disk cataloging - save to csv?

I'm working on a Windows batch script that creates a directory/file listing of a complete hard disk for archival/cataloging purposes, using only command line-tools (and open-source/free tools). For each of the entries in the listing I wanted to list the filename, directory where it resides in, the filesize, date a,nd time of the file, and the md5 sum. I have been able to create somewhat a working starting point, but I'm hitting a wall since I'm not sure if it is even possible using the command-line tools in Windows. The command "dir /s /a:-d /o:-d /t:c" gives me a nice overview, but I would like this overview displayed (or saved to) a comma-delimited format. So my questions are:
Can I create a csv file with all the fields I mentioned above, with the standard command-line tools (and a m5 freeware tool for the md5 sums)
Do you know of a better way, or is there a dead simple disk cataloging command-line tool I missed?
Thanks in advance for any tips!
You can use dir /s /a:-d /o:-d /t:c > slam.txt
Then the content of this slam.txt, can be processed by WScript in windows, making a CSV file ...
If you need a WScript ex, I can provide one ?
I know this not an CSV example - but it should be complex enough for pattern inspiration :)
and remember this fil is saved as .js
var what2lookfor = '<rect ';
var forReading = 1, forWriting = 2, forAppending = 8, jx = 0, ix = 0;
var triStateUseDefault = -2, triStateTrue = -1, triStateFalse = 0;
var thisRecord="", validFileTypes="js,xml,txt,php,xsl,css,htm,html" , akkum = "";
var fileArray = [];
var FSO = new ActiveXObject("Scripting.FileSystemObject");
var objFiles = FSO.GetFolder("F:\\xps1710\\jscript\\");
var objFileControl = new Enumerator(objFiles.files);
for (; !objFileControl.atEnd(); objFileControl.moveNext()) {
objFile = FSO.GetFile(objFileControl.item());
var ext = objFile.Name.split(".");
if (validFileTypes.indexOf(ext[1]) > 1) {
fileArray[ix] = "F:\\xps1710\\jscript\\" + objFile.Name;
ix++;
}
}
for (zx = 0 ; zx < ix ; zx++ ) {
var file2Traverse = FSO.OpenTextFile(fileArray[zx], forReading, triStateUseDefault );
while (!file2Traverse.AtEndOfStream) {
thisRecord = file2Traverse.ReadLine();
if (thisRecord.indexOf(what2lookfor) > 1 ) {
akkum = akkum + fileArray[zx] + '::' + thisRecord + '\n';
break;
}
}
}
WScript.Echo(akkum);

Best way to wrap rsync progress in a gui?

I use rsync to synchronize files to Windows clients in a server agnostic way. What methods are available to send the progress of rsync to the parent process for display in a gui progress bar?
I imagine two or three choices exist. (1) Watch STDOUT (2) Watch rsync.exe log file, similar to unix tail (3) Watch rsync console output in memory.
Which one is best/preferred?
For this type of tasks, I use my own AutoIt script (freeware, Windows only). The script redirects the standard output into a graphical window, displaying it with the ability to scroll back, etc (very useful in long processes like XCOPYs / PKZIPs to check if any error did happen).
I use AutoIt because it's free, very easy to use, and can compile quickly into an .EXE. I think it's an excellent alternative to a complete programming language for this type of tasks. The downside is that it's for Windows only.
$sCmd = "DIR E:\*.AU3 /S" ; Test command
$nAutoTimeout = 10 ; Time in seconds to close window after finish
$nDeskPct = 60 ; % of desktop size (if percent)
; $nHeight = 480 ; height/width of the main window (if fixed)
; $nWidth = 480
$sTitRun = "Executing process. Wait...." ;
$sTitDone = "Process done" ;
$sSound = #WindowsDir & "\Media\Ding.wav" ; End Sound
$sButRun = "Cancel" ; Caption of "Exec" button
$sButDone = "Close" ; Caption of "Close" button
#include <GUIConstants.au3>
#include <Constants.au3>
#Include <GuiList.au3>
Opt("GUIOnEventMode", 1)
if $nDeskPct > 0 Then
$nHeight = #DesktopHeight * ($nDeskPct / 100)
$nWidth = #DesktopWidth * ($nDeskPct / 100)
EndIf
If $CmdLine[0] > 0 Then
$sCmd = ""
For $nCmd = 1 To $CmdLine[0]
$sCmd = $sCmd & " " & $CmdLine[$nCmd]
Next
; MsgBox (1,"",$sCmd)
EndIf
; AutoItSetOption("GUIDataSeparatorChar", Chr(13)+Chr(10))
$nForm = GUICreate($sTitRun, $nWidth, $nHeight)
GUISetOnEvent($GUI_EVENT_CLOSE, "CloseForm")
$nList = GUICtrlCreateList ("", 10, 10, $nWidth - 20, $nHeight - 50, $WS_BORDER + $WS_VSCROLL)
GUICtrlSetFont (-1, 9, 0, 0, "Courier New")
$nClose = GUICtrlCreateButton ($sButRun, $nWidth - 100, $nHeight - 40, 80, 30)
GUICtrlSetOnEvent (-1, "CloseForm")
GUISetState(#SW_SHOW) ;, $nForm)
$nPID = Run(#ComSpec & " /C " & $sCmd, ".", #SW_HIDE, $STDOUT_CHILD)
; $nPID = Run(#ComSpec & " /C _RunErrl.bat " & $sCmd, ".", #SW_HIDE, $STDOUT_CHILD) ; # Con ésto devuelve el errorlevel en _ERRL.TMP
While 1
$sLine = StdoutRead($nPID)
If #error Then ExitLoop
If StringLen ($sLine) > 0 then
$sLine = StringReplace ($sLine, Chr(13), "|")
$sLine = StringReplace ($sLine, Chr(10), "")
if StringLeft($sLine, 1)="|" Then
$sLine = " " & $sLine
endif
GUICtrlSetData ($nList, $sLine)
_GUICtrlListSelectIndex ($nList, _GUICtrlListCount ($nList) - 1)
EndIf
Wend
$sLine = " ||"
GUICtrlSetData ($nList, $sLine)
_GUICtrlListSelectIndex ($nList, _GUICtrlListCount ($nList) - 1)
GUICtrlSetData ($nClose, $sButDone)
WinSetTitle ($sTitRun, "", $sTitDone)
If $sSound <> "" Then
SoundPlay ($sSound)
EndIf
$rInfo = DllStructCreate("uint;dword") ; # LASTINPUTINFO
DllStructSetData($rInfo, 1, DllStructGetSize($rInfo));
DllCall("user32.dll", "int", "GetLastInputInfo", "ptr", DllStructGetPtr($rInfo))
$nLastInput = DllStructGetData($rInfo, 2)
$nTime = TimerInit()
While 1
If $nAutoTimeout > 0 Then
DllCall("user32.dll", "int", "GetLastInputInfo", "ptr", DllStructGetPtr($rInfo))
If DllStructGetData($rInfo, 2) <> $nLastInput Then
; Tocó una tecla
$nAutoTimeout = 0
EndIf
EndIf
If $nAutoTimeout > 0 And TimerDiff ($nTime) > $nAutoTimeOut * 1000 Then
ExitLoop
EndIf
Sleep (100)
Wend
Func CloseForm()
Exit
EndFunc
.NET has a pretty straight forward way to read and watch STDOUT.
I guess this would be the cleanest way, since it is not dependent on any external files, just the path to rsync. I would not be too surprised if there is a wrapper library out there either. If not, write and open source it :)
I've built my own simple object for this, I get a lot of reuse out of it, I can wrap it with a cmdline, web page, webservice, write output to a file, etc---
The commented items contain some rsync examples--
what I'd like to do sometime is embed rsync (and cygwin) into a resource & make a single .net executable out of it--
Here you go:
Imports System.IO
Namespace cds
Public Class proc
Public _cmdString As String
Public _workingDir As String
Public _arg As String
Public Function basic() As String
Dim sOut As String = ""
Try
'Set start information.
'Dim startinfo As New ProcessStartInfo("C:\Program Files\cwRsync\bin\rsync", "-avzrbP 192.168.42.6::cdsERP /cygdrive/s/cdsERP_rsync/gwy")
'Dim startinfo As New ProcessStartInfo("C:\Program Files\cwRsync\bin\rsync", "-avzrbP 10.1.1.6::user /cygdrive/s/cdsERP_rsync/gws/user")
'Dim startinfo As New ProcessStartInfo("C:\windows\system32\cscript", "//NoLogo c:\windows\system32\prnmngr.vbs -l")
Dim si As New ProcessStartInfo(_cmdString, _arg)
si.UseShellExecute = False
si.CreateNoWindow = True
si.RedirectStandardOutput = True
si.RedirectStandardError = True
si.WorkingDirectory = _workingDir
' Make the process and set its start information.
Dim p As New Process()
p.StartInfo = si
' Start the process.
p.Start()
' Attach to stdout and stderr.
Dim stdout As StreamReader = p.StandardOutput()
Dim stderr As StreamReader = p.StandardError()
sOut = stdout.ReadToEnd() & ControlChars.NewLine & stderr.ReadToEnd()
'Dim writer As New StreamWriter("out.txt", FileMode.CreateNew)
'writer.Write(sOut)
'writer.Close()
stdout.Close()
stderr.Close()
p.Close()
Catch ex As Exception
sOut = ex.Message
End Try
Return sOut
End Function
End Class
End Namespace
Check out DeltaCopy. It is a Windows GUI for rsync.
Check NAsBackup Its open source software that give Windows user Rsync GUI using Watch STDOUT.

Resources