aplay.cs 934 B

1234567891011121314151617181920212223242526272829303132
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Diagnostics;
  5. namespace Speech.play {
  6. public class aplay : IPlaySystem {
  7. public Process Play(string path, string Device, int freq = 8000) {
  8. //aplay -c 1 -t wav -r 22050 -f mu_law foobar
  9. Process p = new Process();
  10. List<string> arg = new List<string>();
  11. if (!String.IsNullOrEmpty(Device))
  12. arg.Add("--device " + Device);
  13. if (freq>0)
  14. arg.Add("--rate " + freq.ToString());
  15. arg.Add("--t wav");
  16. arg.Add("\"" + path + "\"");
  17. p.StartInfo.FileName = "aplay " + String.Join(' ', arg);
  18. p.StartInfo.WorkingDirectory = Environment.CurrentDirectory;
  19. p.StartInfo.CreateNoWindow = true;
  20. return p;
  21. }
  22. public string GetName() {
  23. return "APlay";
  24. }
  25. }
  26. }