Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
executing no output or response
#1
The following code can be successfully executed in LINQPad, but after executing it in LA, there is no output or response.


Code:
Copy      Help
/*/ role exeProgram; nuget Edgettssharp\Edge_tts_sharp; /*/ //.
using Edge_tts_sharp;

script.setup(trayIcon: true, sleepExit: true);
//..

var voice = Edge_tts.GetVoice().FirstOrDefault(i => i.Name == "Microsoft Server Speech Text to Speech Voice (zh-CN, XiaoxiaoNeural)");
Edge_tts.PlayText("hello world", voice);

I've encountered a similar situation before. Can we add a prompt message to the output pane for this scenario?
#2
I guess PlayText is async, ie in other thread. The main should wait. Or, if you can access the playback thread, set its Background property = false.
#3
Here is the source code link. How do I call it as a library in LA?

https://github.com/Entity-Now/Edge_tts_sharp
 
Code:
Copy      Help
// Get a PlayerAudio object
static void getPlayer(string msg, eVoice voice)
{
    var player = Edge_tts.GetPlayer(msg, voice);

    Console.WriteLine("Start playing");
    player.PlayAsync();
    Thread.Sleep(3000);

    Console.WriteLine("Pause playback");
    player.Pause();
    Thread.Sleep(3000);

    Console.WriteLine("Resume playback");
    player.PlayAsync();
    Thread.Sleep(5000);

    player.Stop();
    Console.WriteLine("Playback ended");
}
#4
Not sure if this will help you, but there is an output (in English, sorry - "The Monkey is Hungry!"). This is cobbled together from one of the test programs in the repo. The unused code and comments haven't been cleaned up, apologies.
 
Code:
Copy      Help
// script ""
/*/ nuget t2s\Edge_tts_sharp; /*/


// See https://aka.ms/new-console-template for more information

using Edge_tts_sharp;
using Edge_tts_sharp.Model;

string msg = string.Empty;

msg = "The Monkey is Hungry!";
// 获取xiaoxiao语音包
var voice = Edge_tts.GetVoice().FirstOrDefault(i=> i.Name == "Microsoft Server Speech Text to Speech Voice (zh-CN, XiaoxiaoNeural)");
// 文字转语音,并且设置语速
getPlayer(msg, voice);
Edge_tts.PlayText(msg, voice);
// TextToAudio();
// SaveAudio();


// 保存音频

static void SaveAudio()
{

    // 获取xiaoxiao语音包
    var voice = Edge_tts.GetVoice().FirstOrDefault(i => i.Name == "Microsoft Server Speech Text to Speech Voice (zh-CN, XiaoxiaoNeural)");
    Edge_tts.SaveAudio("hello Edge~", voice, 0, "C:\\audio");
}

// 文本转语音
static void TextToAudio()
{

    var voice = Edge_tts.GetVoice().First();
    Edge_tts.PlayText("hello Edge~", voice);
}

// 自定义接口使用
static void MyFunc(string msg, eVoice voice)
{

    Edge_tts.Invoke(msg, voice, 0, libaray =>
    {
        // 写入自己的操作
        // ...

    } );
}

// 获取一个PlayerAudio对象
static void getPlayer(string msg, eVoice voice)
{

    var player = Edge_tts.GetPlayer(msg, voice);

    Console.WriteLine("开始播放");
    player.PlayAsync();
    Thread.Sleep(3000);


    Console.WriteLine("暂停播放");
    player.Pause();
    Thread.Sleep(3000);

    Console.WriteLine("继续播放");
    player.PlayAsync();
    Thread.Sleep(5000);

    player.Stop();
    Console.WriteLine("结束播放");
}

Best regards,
burque505
#5
Gintaras burque505
thanks for your help!


Forum Jump:


Users browsing this thread: 2 Guest(s)