Using <Python.h> function call in an cpp OBS plugin crash

Hrothgor

New Member
I am doing my own plugin for obs in c++. At the moment my plugin work and do some stuff, I am still learning the API.
I wanted to use Python.h to call some python function. When I use Python.h outside my plugin for some test it work perfectly. Like just
PyRun_SimpleString("print('HelloWorld!')");
But when I do this inside my plugin it always core dump.

Anyone already used Python.h in cpp obs plugin ?
 

Lain

Forum Admin
Lain
Forum Moderator
Developer
While it is not impossible to invoke a python script from C/C++ from a plugin, you probably shouldn't attempt to do that. The way the OBS links with python is at runtime. It's a bit convoluted but allows us to use python without having to include it as part of our program. I could put in a something to execute scripts from C/C++ plugins, but I would first be curious as to why you're trying to do that, and your overarching goals.
 

Hrothgor

New Member
While it is not impossible to invoke a python script from C/C++ from a plugin, you probably shouldn't attempt to do that. The way the OBS links with python is at runtime. It's a bit convoluted but allows us to use python without having to include it as part of our program. I could put in a something to execute scripts from C/C++ plugins, but I would first be curious as to why you're trying to do that, and your overarching goals.
I wan't to convert speech from obs source audio to text. But I am strugling too hard to do it with cpp, so I found I could do it in 10 lines with python and default mic computer. I found a plugin (https://github.com/ratwithacompiler/OBS-captions-plugin) that does what I want but I only want the output text and his github is too complex.
 
Top