-3

I have to make a voice controlled mobile game that is similar to Flappy Bird. The character's movement is controlled by voice pitch. I have found only one tutorial, but it uses Python and I'm using C# (Unity). I would like to use the libraries used in the tutorial (aubio and Music21), I've searched for their "C# counterparts" but couldn't find any. Is there a way to use those python libraries in C#? I've read you can run Python scripts from C# with cmd, but I don't think it would work for me as I'm developping a mobile game.

Yar Mommy
  • 55
  • 9
  • I'd advise just using the c# libraries. Each language has their own libraries, which work best with it. Plus, you'll learn a bit more about the power of .NET – Frontear Nov 26 '18 at 19:38

1 Answers1

2

It's slightly limited but you can always try IronPython. It's an open-source implementation of Python with the .NET Framework.

It is limited to Python 2.7, though, so it may not work for you 100%. Example from How do I run a Python script from C#?:

using IronPython.Hosting;
using Microsoft.Scripting.Hosting;

private static void doPython()
{
    ScriptEngine engine = Python.CreateEngine();
    engine.ExecuteFile(@"test.py");
}
jhomr
  • 477
  • 3
  • 16
  • This feels like it should be a comment. – itsme86 Nov 26 '18 at 18:32
  • 1
    How so? They asked if there was a way to use Python libraries in C#. That's what I gave them. – jhomr Nov 26 '18 at 18:34
  • 1
    Because there's no details. You basically provided a link to something. If you fleshed it out a little, it would feel like an answer. As it stands, it feels like a comment. – itsme86 Nov 26 '18 at 18:38
  • 2
    Done. Thanks :) – jhomr Nov 26 '18 at 18:43
  • 1
    @itsme86 Comments are not for answers that are less detailed. If you think that an answer is insufficiently detailed then you think it's a bad answer, not a comment. Comments are for improving the posts that they're commenting on, rather than answers that aren't as detailed. If you feel like an answer lacks details, say it lacks details, don't say it should be a comment. – Servy Nov 26 '18 at 18:54
  • @itsme86 Sure, "When shouldn't I comment? [...] Answering a question or providing an alternate solution to an existing answer; instead, post an actual answer (or edit to expand an existing one);" Notice how "answering a question" is in the "when *shouldn't* I comment?" section, rather than the "when *should* I comment?" section. – Servy Nov 26 '18 at 19:14
  • 1
    Rather than executing a script, I want to use functions from those Python libraries and work with its output within C#... – Yar Mommy Nov 26 '18 at 19:27
  • IronPython does allow using libraries. Just not sure if the specific ones you want to use are compatible with 2.7, that's all. – jhomr Nov 26 '18 at 19:28