Имя пользователя:
Пароль:  
Помощь | Регистрация | Забыли пароль?  

Показать сообщение отдельно

Старожил


Сообщения: 286
Благодарности: 10

Профиль | Отправить PM | Цитировать


Vadikan, увы. открывает в том же окне .


весь скрипт с формой и т.д (на всякий)
Код: Выделить весь код
Add-Type -assembly System.Windows.Forms
[System.Windows.Forms.Application]::EnableVisualStyles()
$p=$MyInvocation.MyCommand.Path | Split-Path -Parent
$s=$p.TrimEnd("\bin")

$json = Get-Content $p\text.json | ConvertFrom-Json


 
$main_form = New-Object System.Windows.Forms.Form
$main_form.Text ='google text-to-speech'
$main_form.Width = 700
$main_form.Height = 700
$main_form.AutoSize = $true


$label5 = New-Object System.Windows.Forms.Label
$label5.Location = New-Object System.Drawing.Point(300, 135)
$label5.Size = New-Object System.Drawing.Size(200, 35)
$label5.Text = "Кол-во символов: 
Максимум - 9000"
$main_form.Controls.Add($label5)

 
$label3 = New-Object System.Windows.Forms.Label
$label3.Location = New-Object System.Drawing.Point(23, 135)
$label3.Size = New-Object System.Drawing.Size(98, 23)
$label3.Text = "Ввод Текста:"
$main_form.Controls.Add($label3)
 
$TextBox = New-Object System.Windows.Forms.TextBox
$TextBox.Width = 628
$TextBox.Height = 460
$TextBox.AutoSize = $true
$TextBox.Location  = New-Object System.Drawing.Point(25,180)
$TextBox.Multiline = $True;
$TextBox.Text = Get-Clipboard -Format Text
$TextBox.Add_KeyDown({
  if ($_.Modifiers -eq [System.Windows.Forms.Keys]::Control -and $_.KeyCode -eq [System.Windows.Forms.Keys]::A) {
     $TextBox.SelectAll()
  }
})
$main_form.Controls.Add($TextBox)



 
$button = New-Object System.Windows.Forms.Button
$button.Text = 'Start'
$button.Location = New-Object System.Drawing.Point(470,54)
$button.add_Click({Click_Button});
$main_form.Controls.Add($button)




$label = New-Object System.Windows.Forms.Label
$label.Location = New-Object System.Drawing.Point(40, 32)
$label.Size = New-Object System.Drawing.Size(98, 23)
$label.Text = "Выбор голоса:"
$main_form.Controls.Add($label)

$comboBox = New-Object System.Windows.Forms.ComboBox
$comboBox.Items.Insert(0, "ru-RU-Wavenet-A");
$comboBox.Items.Insert(1, "ru-RU-Wavenet-B");
$comboBox.Items.Insert(2, "ru-RU-Wavenet-C");
$comboBox.Items.Insert(3, "ru-RU-Wavenet-D");
$comboBox.Items.Insert(4, "ru-RU-Wavenet-E");
$comboBox.SelectedIndex = "1"
$comboBox.Location = New-Object System.Drawing.Point(25, 55)
$comboBox.Size = New-Object System.Drawing.Size(120, 310)
$main_form.Controls.Add($comboBox)







$label1 = New-Object System.Windows.Forms.Label
$label1.Location = New-Object System.Drawing.Point(205, 32)
$label1.Size = New-Object System.Drawing.Size(98, 23)
$label1.Text = "Скорость:"
$main_form.Controls.Add($label1)

$comboBox1 = New-Object System.Windows.Forms.ComboBox
$comboBox1.Items.Insert(0, 0.25)
$comboBox1.Items.Insert(1, 0.5)
$comboBox1.Items.Insert(2, 0.75)
$comboBox1.Items.Insert(3, 1)
$comboBox1.Items.Insert(4, 1.1)
$comboBox1.Items.Insert(5, 1.5)
$comboBox1.Items.Insert(6, 1.75)
$comboBox1.Items.Insert(7, 2)
$comboBox1.Items.Insert(8, 2.25)
$comboBox1.Items.Insert(9, 2.5)
$comboBox1.Items.Insert(10, 2.75)
$comboBox1.Items.Insert(11, 3)
$comboBox1.Items.Insert(12, 3.5)
$comboBox1.Items.Insert(13, 3.75)
$comboBox1.Items.Insert(14, 4)
$comboBox1.SelectedIndex = "3"
$comboBox1.Location = New-Object System.Drawing.Point(175, 55)
$comboBox1.Size = New-Object System.Drawing.Size(120, 310)
$main_form.Controls.Add($comboBox1)









$label2 = New-Object System.Windows.Forms.Label
$label2.Location = New-Object System.Drawing.Point(340, 32)
$label2.Size = New-Object System.Drawing.Size(98, 23)
$label2.Text = "Тональность:"
$main_form.Controls.Add($label2)

$comboBox2 = New-Object System.Windows.Forms.ComboBox
$comboBox2.Items.Insert(0, -5);
$comboBox2.Items.Insert(1, -4);
$comboBox2.Items.Insert(2, -3);
$comboBox2.Items.Insert(3, -2);
$comboBox2.Items.Insert(4, -1);
$comboBox2.Items.Insert(5, 0);
$comboBox2.Items.Insert(6, 1);
$comboBox2.Items.Insert(7, 2);
$comboBox2.Items.Insert(8, 3);
$comboBox2.Items.Insert(9, 4);
$comboBox2.Items.Insert(10, 5);
$comboBox2.SelectedIndex = "5"
$comboBox2.Location = New-Object System.Drawing.Point(325, 55)
$comboBox2.Size = New-Object System.Drawing.Size(120, 310)
$main_form.Controls.Add($comboBox2)




 
function Click_Button
{ 
	$json.input.text = $TextBox.Text;
	$json.voice.name = $comboBox.SelectedItem;
	$json.audioConfig.pitch = $comboBox2.SelectedItem;
	$json.audioConfig.speakingRate = $comboBox1.SelectedItem;
	$json | ConvertTo-Json | Set-Content $p\text.json;
	

$file = gc $p/text.json
$enc = [system.text.encoding]
function psiconv ( $f, $t, $string ) {
    $cp1          = $enc::getencoding( $f )
    $cp2          = $enc::getencoding( $t )
    $inputbytes   = $enc::convert( $cp1, $cp2, $cp2.getbytes( $string ))
    $outputstring = $cp2.getstring( $inputbytes )
    
    $outputstring | add-content $p/text1.json  
}
foreach ($string in $file) {
    psiconv -f "windows-1251" -t "utf-8" $string
}


del $p/text.json
Rename-Item -path $p/text1.json -NewName $p/text.json
del $p/source.txt
del $p/out.txt



	$main_form.Close()

.\params.ps1

}

$main_form.ShowDialog()

Последний раз редактировалось 9119, 19-12-2020 в 14:29.


Отправлено: 13:44, 19-12-2020 | #5