using System.Net;
using System.Media;
using System.IO;
using System;
using WMPLib;
namespace ConsoleApp2
{
internal class Program
{
static void Main(string[] args)
{
string text = "Xin chào bạn, tôi là trại huấn luyện cốt đơ ci sáp";
string url = "https://translate.google.com/translate_tts?ie=UTF-8&client=tw-ob&tl=vi&q="
+ Uri.EscapeDataString(text);
string filePath = "tts.mp3"; //wav
// 🔹 Tải file mp3
using (WebClient wc = new WebClient())
{
wc.DownloadFile(url, filePath);
}
// 🔹 Phát mp3
WindowsMediaPlayer player = new WindowsMediaPlayer();
player.URL = filePath;
player.controls.play();
Console.WriteLine("Đang phát...");
Console.ReadKey();
}
}
}
Hướng dẫn đọc tiếng việt csharp