function showTranscribe($owner) { $form = New-Object System.Windows.Forms.Form $form.Owner = $owner $form.icon = $icon $form.Text = "Transcribir" $form.Width = 445 $form.Height = 455 $form.AutoSize = $true $form.MaximizeBox = $false $form.StartPosition = [System.Windows.Forms.FormStartPosition]::CenterParent $form.Font = "Microsoft Sans Serif, 9.35" $form.FormBorderStyle = 'FixedDialog' $label_ori = New-Object System.Windows.Forms.Label $label_ori.Text = "Archivo:" $label_ori.AutoSize = $true $label_ori.Location = New-Object System.Drawing.Point(20, 23) $text_ori = New-Object System.Windows.Forms.TextBox $text_ori.Text = $sel_ori $text_ori.Width = 255 $text_ori.Location = New-Object System.Drawing.Point(75, 20) $text_ori.add_DoubleClick({ $text_ori.SelectAll(); }) $btn_ori = New-Object System.Windows.Forms.Button $btn_ori.Text = "Examinar" $btn_ori.AutoSize = $true $btn_ori.Location = New-Object System.Drawing.Point(335, 18) $btn_ori.Add_Click({ $res = selectFile -path "" -formats "Video o audio (*.*)|*.*" -multi $false if ($null -ne $res) { $text_ori.Text = $res } }) $label_model = New-Object System.Windows.Forms.Label $label_model.Text = "Modelo:" $label_model.AutoSize = $true $label_model.Location = New-Object System.Drawing.Point(20, 60) $list_model = New-Object System.Windows.Forms.ComboBox $list_model.Width = 255 $list_model.DropDownStyle = [System.Windows.Forms.ComboBoxStyle]::DropDownList; $list_model.Location = New-Object System.Drawing.Point(75, 57) $trans_models = Get-ChildItem -Path $transcriber_models | Sort-Object -Property Length | Select-Object Name foreach ($model in $trans_models) { $list_model.Items.add((($model -split ".bin")[0] -split "Name=")[1]) } $list_model.SelectedIndex = 0; $form.Controls.Add($label_model) $form.Controls.Add($list_model) $btn_optim = New-Object System.Windows.Forms.Button $btn_optim.Text = "Optimizar" $btn_optim.AutoSize = $true $btn_optim.Location = New-Object System.Drawing.Point(335, 55) $btn_optim.Add_Click({ optimizeTranscriber $global:transcriber = getTranscriber }) $label_lang = New-Object System.Windows.Forms.Label $label_lang.Text = "Idioma:" $label_lang.AutoSize = $true $label_lang.Location = New-Object System.Drawing.Point(20, 98) $list_lang = New-Object System.Windows.Forms.ComboBox $list_lang.Width = 333 $list_lang.DropDownStyle = [System.Windows.Forms.ComboBoxStyle]::DropDownList; $list_lang.Location = New-Object System.Drawing.Point(75, 95) foreach ($lang in ($transcriber_langs -split ",")) { $list_lang.Items.add($lang) } $list_lang.SelectedIndex = 0; $form.Controls.Add($label_lang) $form.Controls.Add($list_lang) $check_translate = New-Object System.Windows.Forms.Checkbox $check_translate.Location = New-Object System.Drawing.Point(75, 128) $check_translate.AutoSize = $true $check_translate.Text = "Traducir (al inglés)" $check_translate.Checked = $false $form.Controls.Add($check_translate) $label_output = New-Object System.Windows.Forms.Label $label_output.Text = "Transcripción:" $label_output.AutoSize = $true $label_output.Location = New-Object System.Drawing.Point(20, 158) $form.Controls.Add($label_output) $text_output = New-Object System.Windows.Forms.TextBox $text_output.Multiline = $True; $text_output.Location = New-Object System.Drawing.Point(20, 180) $text_output.Size = New-Object System.Drawing.Size(388, 100) $text_output.Scrollbars = "Vertical" $text_output.ReadOnly = $true $form.Controls.Add($text_output) $text_output.add_DoubleClick({ $text_output.SelectAll(); }) $text_output.Add_KeyDown({ if (($_.KeyCode -eq "A") -and $_.Control) { $text_output.SelectAll(); } }) $label_subs = New-Object System.Windows.Forms.Label $label_subs.Text = "Obtener subtítulos:" $label_subs.AutoSize = $true $label_subs.Location = New-Object System.Drawing.Point(20, 293) $form.Controls.Add($label_subs) $btn_burn = New-Object System.Windows.Forms.Button $btn_burn.Text = "Incrustados" $btn_burn.Location = New-Object System.Drawing.Point(20, 318) $btn_burn.Width = 90 $btn_burn.Height = 30 $btn_burn.enabled = $false $form.Controls.Add($btn_burn) $btn_burn.Add_Click({ $filename = selectSaveFile -filename "$((Get-Item $text_ori.Text).Basename) - Subtitulado.$def_video_fmt" -extension $def_video_fmt if ($filename) { mix_transcribed -source $text_ori.Text -subs $global:output.vtt -subs_mode "burn" -out $filename } }) $btn_attach = New-Object System.Windows.Forms.Button $btn_attach.Text = "Adjuntos" $btn_attach.Location = New-Object System.Drawing.Point(120, 318) $btn_attach.Width = 90 $btn_attach.Height = 30 $btn_attach.enabled = $false $form.Controls.Add($btn_attach) $btn_attach.Add_Click({ $filename = selectSaveFile -filename "$((Get-Item $text_ori.Text).Basename) - Subtitulado.$def_video_fmt" -extension $def_video_fmt if ($filename) { mix_transcribed -source $text_ori.Text -subs $global:output.vtt -subs_mode "attach" -out $filename } }) $btn_vtt = New-Object System.Windows.Forms.Button $btn_vtt.Text = "VTT" $btn_vtt.Location = New-Object System.Drawing.Point(220, 318) $btn_vtt.Width = 90 $btn_vtt.Height = 30 $btn_vtt.enabled = $false $form.Controls.Add($btn_vtt) $btn_vtt.Add_Click({ saveFile -data $global:output.vtt -filename "$((Get-Item $text_ori.Text).Basename).$def_sub_fmt" -extension $def_sub_fmt }) $btn_csv = New-Object System.Windows.Forms.Button $btn_csv.Text = "CSV" $btn_csv.Location = New-Object System.Drawing.Point(320, 318) $btn_csv.Width = 90 $btn_csv.Height = 30 $btn_csv.enabled = $false $form.Controls.Add($btn_csv) $btn_csv.Add_Click({ saveFile -data $global:output.csv -filename "$((Get-Item $text_ori.Text).Basename).csv" -extension "csv" }) $btn_exec = New-Object System.Windows.Forms.Button $btn_exec.Text = "Transcribir" $btn_exec.Location = New-Object System.Drawing.Point(140, 370) $btn_exec.Width = 150 $btn_exec.Height = 30 $btn_exec.Add_Click({ try { $prevCode = startAlwaysOn $global:output = transcribe -in $text_ori.Text -model $list_model.SelectedItem -language $list_lang.SelectedItem -translate $check_translate.Checked if ($global:output) { $btn_vtt.enabled = $true $btn_csv.enabled = $true $btn_burn.enabled = $true $btn_attach.enabled = $true $text_output.Text = $global:output.txt.Trim() } else { $text_output.Text = "Error" } } finally { endAlwaysOn -code $prevCode } }) $form.Controls.Add($btn_exec) $form.Controls.Add($label_ori) $form.Controls.Add($text_ori) $form.Controls.Add($btn_ori) $form.Controls.Add($label_dest) $form.Controls.Add($text_dest) $form.Controls.Add($btn_dest) $form.Controls.Add($label_name) $form.Controls.Add($btn_optim) $form.Controls.Add($text_name) $text_ori.Select() $form.Add_Closing({ $owner.Location = getRelativeLocation -parent $owner -child $form $form.Hide() $owner.Show() }) [PSAppID]::SetAppIdForWindow($form.handle, "$($metadata.package).$app_name") $form.Add_LocationChanged({ $global:win_loc = $form.Location }) $form.Add_Resize({ $global:win_size = $form.Size }) $form.ShowDialog() return $form }