Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

helppppp! #3

Open
Sarvinkhan opened this issue Apr 5, 2024 · 2 comments
Open

helppppp! #3

Sarvinkhan opened this issue Apr 5, 2024 · 2 comments

Comments

@Sarvinkhan
Copy link

my problem is when i want use the powershell to send farsi phrase to piper, the powershell does not support the persian unicode and i want to know that you proceed this project, how you overcome this because i cannot find any solution i the internet.

@karim23657
Copy link

karim23657 commented Apr 6, 2024

@Sarvinkhan ,
The issue you're facing is related to how PowerShell displays and handles text encodings. Here's how to overcome it and run the command with your Persian phrase:

  1. Setting Default Encoding (PowerShell v6+):

If you're using PowerShell Core v6 or later, it defaults to UTF-8 encoding. You can verify this by running:

[System.Text.Encoding]::Default

If it's not UTF-8, add the following line to your PowerShell profile ($PROFILE) to set it permanently:

$PSDefaultParameterValues['*:Encoding'] = 'utf8'

  1. Explicit Encoding for the Phrase (All Versions):

Even if PowerShell is set to UTF-8, the way you entered the phrase might not be interpreted correctly.
Use the [Text.Encoding]:: methods to explicitly encode the Persian text as UTF-8 before piping it to the command:

$phrase = "سلام و درود بر شما"
$bytes = [Text.Encoding]::UTF8.GetBytes($phrase)
$encodedPhrase = [System.BitConverter]::ToString($bytes, [String]::Empty)

echo ($encodedPhrase -join "") | .piper.exe --model .modelsfa_IR-amir-medium.onnx --output_dir .outputs

This encodes the phrase as UTF-8, converts the bytes to a hexadecimal string for clarity, and then pipes it to the echo command.
3. Font Selection:

Ensure your PowerShell console uses a font that supports displaying Persian characters. Common options include Segoe UI or Lucida Sans Unicode. You can change the font in the console properties.

  1. Verifying Output:

After running the command, check the output directory (.outputs) to see if the processed file contains the Persian characters correctly.

@Sarvinkhan
Copy link
Author

@Sarvinkhan , The issue you're facing is related to how PowerShell displays and handles text encodings. Here's how to overcome it and run the command with your Persian phrase:

  1. Setting Default Encoding (PowerShell v6+):

If you're using PowerShell Core v6 or later, it defaults to UTF-8 encoding. You can verify this by running:

[System.Text.Encoding]::Default

If it's not UTF-8, add the following line to your PowerShell profile ($PROFILE) to set it permanently:

$PSDefaultParameterValues['*:Encoding'] = 'utf8'

  1. Explicit Encoding for the Phrase (All Versions):

Even if PowerShell is set to UTF-8, the way you entered the phrase might not be interpreted correctly. Use the [Text.Encoding]:: methods to explicitly encode the Persian text as UTF-8 before piping it to the command:

$phrase = "سلام و درود بر شما"
$bytes = [Text.Encoding]::UTF8.GetBytes($phrase)
$encodedPhrase = [System.BitConverter]::ToString($bytes, [String]::Empty)

echo ($encodedPhrase -join "") | .piper.exe --model .modelsfa_IR-amir-medium.onnx --output_dir .outputs

This encodes the phrase as UTF-8, converts the bytes to a hexadecimal string for clarity, and then pipes it to the echo command. 3. Font Selection:

Ensure your PowerShell console uses a font that supports displaying Persian characters. Common options include Segoe UI or Lucida Sans Unicode. You can change the font in the console properties.

  1. Verifying Output:

After running the command, check the output directory (.outputs) to see if the processed file contains the Persian characters correctly.

if your discord channel is still available, eould please give me an invite link?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants